The super
keyword refers to the immediate parent class object and is used to:
class Parent {
String name = "Parent";
void display() { System.out.println("Parent display"); }
}
class Child extends Parent {
String name = "Child";
Child() {
super(); // Call parent constructor
}
void display() {
super.display(); // Call parent method
System.out.println("Parent name: " + super.name);
}
}