Java super keyword - The Coding Shala
Home >> Learn Java >> Java Super Keyword
Java super keyword
Like Java this keyword, the super keyword is also a reference variable that is used to refer the parent class objects. When we use inheritance need to use parent class object therefore Java super keyword is used to refer the parent class object.
The following are ways to use the Java super keyword:
- Java super keyword is used to refer to the parent class variables. If a child class and Parent class have the same variables then super can be used to identify the parent class variables. The following example explains it:
- Java super keyword can be used to call parent class methods. The following example explains it:
- Using Java super keyword we can also call parent class constructor. The following example explains it:
Note: super() must be the first statement in child class constructor.
Other Posts You May Like