Super Keyword

 

Super Keyword

The super keyword is used to call the constructor of the super class from a sub class. The super keyword always calls the super class. All the methods and variables of the super class can be accessed from the sub class using the super keyword.

Figure 1: Super keyword Example


As Figure 1 shows, the super keyword can be used to retrieve the output of all methods or only one method from the super class. When the super keyword is called to the constructor, the object is created for it and the corresponding output is executed.

Comments

Popular posts from this blog

Polymorphism

Java Standards, Class & Object