0

Parent constructors are not called implicitly if the subclass defines a constructor.

Could you please explain me what is mean by this line??

15th Dec 2019, 8:26 AM
Riya
7 Réponses
+ 3
Riya if you extend a class and create a constructor for the subclass then the compiler will not provide a default constructor. So you now cannot implicitly call the default constructor of the base class.
15th Dec 2019, 8:36 AM
Avinesh
Avinesh - avatar
+ 2
Riya see a constructor is nothing but a method which is called when an object of the class is created. So if you have a class and do not write any constructor for the class then the compiler will provide a no argument default constructor. Since it is not provided by you, it is called an implicitly provided constructor. Apart from that any constructor you create is called an explicitly provided constructor. Since it is not automatically provided.
15th Dec 2019, 9:33 AM
Avinesh
Avinesh - avatar
0
Avinesh thanks please can u explain what is mean by implicitly & explicitly in terms of inheritance
15th Dec 2019, 8:55 AM
Riya
0
Thanks Avinesh
15th Dec 2019, 11:54 AM
Riya
0
Ok rodwynnejones thanks for suggestion
15th Dec 2019, 11:55 AM
Riya
0
Hi
16th Dec 2019, 4:29 PM
Harun Rashid
Harun Rashid - avatar