0
why the constructor of super class is executed when we create object of sub class?
Please explain the reason...
3 odpowiedzi
+ 1
no constructor no super class
no super class no sub class
+ 1
in the inheritance all the base class variables and methods are available to the derived class so when you create object of the derived class, base class and derived class constructors executed.
similarly father's property can access by his son by default.
+ 1
Constructors get initialized when their class object is created.
When we inherit(extends) a class with DEFAULT constructor, the constructor gets automatically TRIGGERED because it doesn't require any parameter, when its object is created, voila! You have the TRIGGERED constructor executed