Super keyword in Java.


  • mkCodingmkCoding Atlanta, GA

    you use the "super" keyword when you are referring to a parent class
    for example:

    //super-class to class Bike
    public class Vehicle{
    int speed =50;
    //Bike is a subclass to Vehicle
    public class Bike extends Vehicle{
    void display(){
    //super keyword used to retrieve value or call method from parent class

    "super" is only used when the current class you're in has a parent/super-class.
    hope this helps

  • Super keyword is used to refer the methods, Constructor and variable of the super class.

    It is used to implement the concept of "Method Overriding".

    When there is same method defined in base and subclass then method of subclass overrides the super class method. So, To call the method of superclass, we use super() keyword.

    For more Details Refer following link:

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!