+ 2
Why "super" keyword must be the first statement in constructor
3 Respuestas
+ 11
Because a child cannot exist without parents... Just like in real life. A child object cannot do anything before the parent object is initialized.
If you don't write it down, it will get called implicitly to make sure the parent class exists.
+ 3
The superclass' [parent/ base] constructor needs to be called before the subclass' constructor. This will ensure that if you call any methods on the superclass in your constructor, the superclass has already been set up correctly.
In other words, superclass acts as the tree and the subclass acts as its fruit; which means without the source you can’t obtain the object.
As @Tashi N mentioned:
parent-> superclass, baby-> subclass.
Good luck!
CA
0
Cris Ahmad thank you 😊