Learn Pain Less

HomeOur TeamContact
Java
What is default constructor in JAVA
Pawneshwer Gupta
Pawneshwer Gupta
March 23, 2015
1 min
What is default constructor in JAVA

Default constructor in java

Default constructor doesn’t have parameters. And default constructor exists in class if we doesn’t create constructor inside class. If we create any constructor having 1,2,3 parameters then there is no default constructor anymore. We need to create default constructor manually in this case.

Example of default constructor:

class Android {
public static void main(String[] a){
Android a = new Android(); //default constructor in java
}
}

In the following example i haven’t created any constructor inside class Android, but inside main method i created an instance of Android class using constructor without any parameters. This is default constructor. And that is the use off default constructor.

Subscribe to our newsletter!

We'll send you the best of our blog just once a month. We promise.

Tags

startconstructordefault constructorjava tutorial

Share


Pawneshwer Gupta

Pawneshwer Gupta

Software Developer

Pawneshwer Gupta works as a software engineer who is enthusiastic in creating efficient and innovative software solutions.

Expertise

Python
Flutter
Laravel
NodeJS

Social Media

Related Posts

Working with Files, Folders java
Working with Files, Folders java
March 25, 2015
1 min
Learn Pain Less  © 2024, All Rights Reserved.
Crafted with by Prolong Services

Quick Links

Advertise with usAbout UsContact Us

Social Media