Variables and methods of the superclass can be overridden in the subclass. In case of overriding, a subclass
object calls its own variables and methods.
A subclass cannot access the variables and methods of a superclass because the overridden variables or methods hide the methods and variables of the superclass. But still, java provides a way to access superclass members even if its members are overridden. Super is used to access superclass variables, methods, and constructors. Super if present must be the first statement.
Super can be used in two forms
- The first form is for calling the superclass constructor.
- The second one is to call super class variables and methods.