What is default constructor in JAVA

Fetching Comments ...
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.

Featured Posts

post preview
post preview
post preview
post preview
post preview

JOIN SOCIAL ACCOUNTS

Related Posts

Get The Best Of All Hands Delivered To Your Inbox

Subscribe to our newsletter and stay updated.