In Java, the super keyword is used to access variables and methods of a super class from a sub class. For example:

public class Super {
    protected int number;
    
    protected showNumber() {
        System.out.println("number = " + number);
    }
}

public class Sub extends Super {
    void bar() {
        super.number = 10;
        super.showNumber();
    }
}

In the above example, the class Sub accesses the variable number and calls the method showNumber() for its super class Super.

Related keyword: this. See all keywords in Java.

  

Other Recommended Tutorials:


About the Author:

is certified Java programmer (SCJP and SCWCD). He started programming with Java in the time of Java 1.4 and has been falling in love with Java since then. Make friend with him on Facebook and watch his Java videos you YouTube.



Add comment

   


Comments 

#2SAM2017-09-11 07:16
class Super {
protected int number;
protected void showNumber(){
System.out.println("numer : " +number);
}
}

public class SubClassTest extends Super {
void bar(){
super.number =10;
super.showNumber();
}
public static void main(String[]args) {
SubClassTest obj = new SubClassTest();
obj.bar();
}
}
Quote
#1ARUN REDDY2017-09-10 06:45
SEND THE "THIS ,STATIC,SUPER KEYWORDS
Quote