What is the significance of the super keyword in Java?
The super keyword in Java is used to reference members of a superclass from within a subclass. It is significant in the following ways:
Accessing Superclass Members
It allows access to the fields, methods, or constructors of a superclass when they are hidden by subclass members of the same name.
Calling Superclass Methods
super is used to call methods of the superclass that have been overridden in the subclass.
class Parent {
void show() { System.out.println(“Parent Method”); }
}
class Child extends Parent {
void show() {
super.show(); // Calls Parent’s method
System.out.println(“Child Method”);
}
}