In a sub class if you dont provide a constructor.......then it will automatically call the no argumented constructor of the super class.
If the constructor is provided in the sub class, then through the super keyword the constructors of the super class can be inherited for both argumented and non-agrumented. whether implicit or explicit call of construtors 'constructor chaining happens to the object class's constrtuctors.
Experts please correct me if i am wrong.
Be Objectively Oriented.Explore the power of OOPs.
My Blog, Eclipse EMF Query committer.
inerit a constructor is not s proper definition. Your class inerit from its parent anyway you can say that the constructors of your your class can instantiate one of the constructors of its parent; which one is your choose.
If you have something like
when you intantiate
when you intantiate or
it automatically call the default constructor of the animal class Animal.
But if you instantiate
it will call the constructor of Animal which take a String as parameter.
This process can be replicated if you another class extends the Mammal class; take the example below
the constructor Dog(String name) will instantiate (in order) the following contructors 1) Animal() 2) Mammal(int numLegs) 3) Dog(String name)
on the other side the Dog() will instantiate 1) Animal(String name) 2) Mammal(String name) 3) Dog()