+ 1

What is use of default constructor and constructor???

9th Jul 2017, 1:19 AM
mahendra
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.
9th Jul 2017, 1:25 AM
Sandeep Chatterjee
+ 1
thanks
9th Jul 2017, 1:41 AM
mahendra