+ 2

Core java

Every default constructor is a non parameterised constructor. But is the reverse also true? Someone please clear it

5th Apr 2019, 7:17 PM
akshay patel
2 Answers
+ 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..
7th Apr 2019, 8:55 AM
Syntax_error_chaitu
Syntax_error_chaitu - avatar
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.
6th Apr 2019, 8:38 PM
Nonea
Nonea - avatar