super is used to refer immediate parent class instance variable.

We can use super keyword to access the data member or field of parent class. It is used if parent class and child class have same fields.


\begin{lstlisting}
class Animal{
String color=''white'';
}
class Dog extends...
...ain(String args[]){
Dog d=new Dog();
d.printColor();
}
}
\end{lstlisting}

Output:


\begin{lstlisting}
black
white
\end{lstlisting}

In the above example, Animal and Dog both classes have a common property color. If we print color property, it will print the color of current class by default. To access the parent property, we need to use super keyword.