What's the meaning and usage of the super
keyword in Java?
The super keyword refers to superclass (parent) objects. It is used to call superclass methods, and to access the superclass constructor. The most common use of the super keyword is to eliminate the confusion between superclasses and subclasses that have methods with the same name.
super keyword super is used to refer super-class's instance as well as static members. super is also used to invoke super-class's method or constructor. super keyword in java programming language refers to the superclass of the class where the super keyword is currently being used.
Usage of Java super Keyword super can be used to refer immediate parent class instance variable. super can be used to invoke immediate parent class method. super() can be used to invoke immediate parent class constructor.
Only public and protected methods can be called by the super keyword. It is also used by class constructors to invoke constructors of its parent class. Super keyword are not used in static Method.
super
is a keyword in Java. It refers to the immediate parents property.
super() //refers parent's constructor super.getMusic(); //refers to the parent's method
- Read More on super
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With