super
Uses of the super keyword
super keywordclass Parent {
int value = 10;
void display() {
System.out.println("Parent's value: " + value);
}
}
class Child extends Parent {
int value = 20;
void display() {
System.out.println("Child's value: " + value);
System.out.println("Parent's value: " + super.value); // Accessing superclass variable
super.display(); // Invoking superclass method
}
}Last updated