From the previous post, we already know that one of use of the 'super' keyword is to call the constructors in the superclass. Now lets use the 'super' keyword to access the constructors in superclasses in multilevel hierarchy.
But 'super' keyword used in the subclass can only call the constructor in its immediate superclass. It cant call the constructor in the superclass of its superclass. If A is super class of B and B is superclass of C. Then 'super' keyword in 'C' class can only call the constructor of its superclass 'B' class but cant call the constructor of superclass of its superclass i.e. 'A' class.
Lets implement this in Eclipse IDE:
1. Create superclass 'ClassOne' as shown below:
6. Observe that the output is displayed in the console as shown below:
Click here to download the project containing 'ClassOne', 'ClassTwo', 'ClassThree' and 'SuperLevelDemo' class files used in this post (You can download this project and import into Eclipse IDE on your machine)
Please comment below to feedback or ask questions.
'Explicitly Invoke Super class constructor' will be explained in the next post.