+ 2
Core java
Every default constructor is a non parameterised constructor. But is the reverse also true? Someone please clear it
2 Respostas
+ 1
At the time of declaration of an object constructor call will be done implicity by the compiler itself..
Here we will have two cases
case1: If your program doesn't have a constructor definition compiler calls the default constructor(i.e.,non parameterized constructor).
Case2: If your program have a constructor definition it may be of any type compiler calls programmer defined constructor.
Per an object only once a constructor will be called.. that means only once a parameterized constructor and also once a non- parameterized constructor .
That means we can call two constructors(one is parameterized and another is non parameterized constructor)per an object..
0
All classes have a default constructor without parameters even if you did not write any constructor into it. Here default means "compiler-made" I think. And as far as I know compilers make only nullary constructors. As a programmer you can write another constructor(s) but after compilation there will not be any privilege of a default constructor. Simply there must be one at least, complier will guarantee it.