+ 1
What is use of default constructor and constructor???
2 ответов
+ 3
default constructor is the constructor that has no arguments. it gets called and the object is instantiated with default parameters when there is no arguments.
class Animal (){
public name;
public void Animal(){
// default constructor
this.name="tiger";
}
public void Animal( String name){
this.name=name;
}
}
in this case if you don't put name of animal it will automatically set the name of animal as tiger.
+ 1
thanks