I encountered a question that asks \"Which of the following are true about the \"default\" constructor?\"
and an option \"It initializes the instance members of the cla
Default constructor provides the default values to the object (s) and is normally created by the compiler when no constructor is explicitly defined. e.g.
class DefaultTest{
int id;
String name;
void display(){System.out.println(id+" "+name);}
public static void main(String args[]){
DefaultTest s1=new DefaultTest();
DefaultTest s2=new DefaultTest();
s1.display();
s2.display();
}
}
NB: There being no constructor defined the compiler will generate a default constructor that will assign 0 null values to the two objects.