Super Keyword In Java
Java Super Keyword ?
The Java super keyword is used to access a member of the super class from the subclass. Super can only be used within a derived class constructor method.
super keyword has two general froms:-
(i) Calls the superclass constructor and
(ii) Accessing a member of the super class that has been hidden by a member of subclass.
➦A subclass can call a constructor method defined by its superclass by using the super keyword. Whenever you create the instance of subclass, an instance of parent class is created implicitly which is referred by super reference variable.
➦The keyword “super” came into the picture with the concept of Inheritance.
Example 1:
Output :
Animals can not speak Dogs can be dangerous
Example 2:
Output :
eating... barking...
Example 3:
Output :
This is student class This is person class