Java Super Keyword

Super Keyword in Java

May 11th, 2026
8269
7:00 Minutes

A super keyword in Java is a powerful tool that connects a subclass to its parent class. It allows developers to access parent class methods, constructors, and fields directly. Understanding super is important for mastering inheritance, constructor chaining and resolving vagueness in object-oriented programming. I have created this blog to walk you through the meaning, characteristics, use cases, advantages, and disadvantages of the Java Super keyword.

What is the Java Super Keyword?

In Java, the super keyword is a reference variable used within a subclass to access members (methods, fields, and constructors) of its immediate parent class. It has an important role in inheritance by allowing subclasses to interact with and extend the functionality of their parent classes.

Also Read: What is Java Abstraction?

How does super Work Internally in JVM?

Understanding how super works internally gives you deeper clarity beyond syntax. When a subclass calls super, it does not create a new object. Instead, it refers to the already constructed parent portion of the current object. Java objects are created in a top-down hierarchy. This means the parent class constructor executes first and then followed by the child constructor.

1. Reference Resolution

When you use super.method() or super.variable, the compiler resolves the reference at compile time. It determines that the call must target the immediate parent class, bypassing method overriding rules used in normal polymorphism. super also forces access to the parent’s implementation directly. This makes a super compile-time binding mechanism for accessing superclass members.

2. Bytecode Instruction: invokespecial

At the JVM level, when super() or super.method() is used, the compiler generates the invokespecial bytecode instruction. invokespecial is used for:

  • Calling constructors
  • Invoking private methods
  • Calling superclass methods

This instruction ensures that the parent class implementation is executed directly, which skips runtime polymorphic method lookup. This shows that super has special handling at JVM level and is not just syntactic sugar.

3. Constructor Call Chain Behavior

In Java object creation:

  • Memory is allocated.
  • Parent class constructor executes.
  • Child class constructor executes.

If you do not explicitly write super(), the compiler automatically inserts it. It only happens when the parent has a no-argument constructor. In this case, you must explicitly call the parameterized constructor using super(arguments). This ensures proper object initialization order and prevents partially constructed objects.

Master Java Programming with Java Training

Boost your coding skills and gain hands-on knowledge in Java.

Explore Now

super with Interfaces (Java 8+)

After the Java 8 update all interfaces can contain default methods. When a class implements multiple interfaces that define the same default method, ambiguity arises. In such cases, Java allows the use of InterfaceName.super.methodName() to resolve conflicts. This is less commonly discussed but highly relevant in modern Java development.

Example:

interface A {
    default void show() {
        System.out.println("Interface A");
    }
}

interface B {
    default void show() {
        System.out.println("Interface B");
    }
}

class Test implements A, B {
    public void show() {
        A.super.show(); // Calling specific interface method
    }

    public static void main(String[] args) {
        new Test().show();
    }
}

Output:

Interface A

This feature helps resolve the diamond problem in multiple inheritance scenarios using interfaces.

super in Abstract Classes

The super keyword also works with abstract classes. Even though abstract classes may contain abstract methods, they can also include concrete methods and constructors. A subclass can use super to access those implemented members. This is common in enterprise applications where base classes provide partial functionality.

Example:

abstract class Shape {
    Shape() {
        System.out.println("Shape constructor");
    }

    void description() {
        System.out.println("This is a shape");
    }

    abstract void draw();
}

class Circle extends Shape {
    Circle() {
        super();
    }

    void draw() {
        super.description();
        System.out.println("Drawing Circle");
    }

    public static void main(String[] args) {
        Circle c = new Circle();
        c.draw();
    }
}

Output:

Shape constructor
This is a shape
Drawing Circle

Examples of Using the Java Super Keyword

Here are some examples of using the Java super keyword-

1. To call a superclass constructor

Use super () (or super params) at the start of a subclass instructor to initialize inherited parts first.

Example

class Animal {
    Animal() {
        System.out.println("Animal constructor called");
    }
}

class Dog extends Animal {
    Dog() {
        super(); // Calls the constructor of Animal class
        System.out.println("Dog constructor called");
    }
}

public class TestSuper {
    public static void main(String[] args) {
        Dog d = new Dog(); // Output: Animal constructor called
                           //         Dog constructor called
    }
}

2. To access overridden methods

super.methodName() invokes the parent class’s version of a method. This allows you to extend or augment behaviour in subclasses.

Example

class Animal {
    void sound() {
        System.out.println("Animal makes a sound");
    }
}

class Dog extends Animal {
    void sound() {
        super.sound(); // Calls the sound() method of Animal class
        System.out.println("Dog barks");
    }
}

public class TestSuper {
    public static void main(String[] args) {
        Dog d = new Dog();
        d.sound(); // Output: Animal makes a sound
                   //         Dog barks
    }
}

3. To access hidden fields

When subclass and superclass both have identically named fields, super.fieldName lets you reference the parent’s field.

Example

class Animal {
    String color = "white";
}

class Dog extends Animal {
    String color = "black";

    void displayColor() {
        System.out.println("Dog color: " + color);          // Prints the color of Dog class
        System.out.println("Animal color: " + super.color); // Prints the color of Animal class
    }
}

public class TestSuper {
    public static void main(String[] args) {
        Dog d = new Dog();
        d.displayColor(); // Output: Dog color: black
                          //         Animal color: white
    }
}

Read Also: Java Tutorial For Beginners

Additional Java Super Keyword Use Cases

The super keyword is also used in the given contexts-

Java Super Keyword Use Cases

1. Super use case with Methods

The super keyword is used when you need to invoke a parent class’s method from a child class. This becomes important when both the parent and child define a method with the same name. Super allows you to eliminate vagueness and directly call the parent version.

Example

Let’s say it is very much like when you would want to listen to your parent’s advice rather than your own. super.methodName() helps you follow the parent’s behaviour in code -

// superclass Person
class Person {
    void message() {
        System.out.println("This is person class\n");
    }
}

// Subclass Student
class Student extends Person {
    void message() {
        System.out.println("This is student class");
    }

    // Note that display() is only in Student class
    void display() {
        // will invoke or call current class message() method
        message();

        // will invoke or call parent class message() method
        super.message();
    }
}

// Driver Program
class Test {
    public static void main(String args[]) {
        Student s = new Student();
        // calling display() of Student
        s.display();
    }
}

Output

This is a student class

This is a person class

2. Super Use Case with Constructors

The super keyword in Java allows a subclass to invoke its immediate parent class’s constructor. super can call both parameterless (default) and parameterized constructors.

Example

The parent exists before a child is born. Just like that the parent class constructor must be there before the child’s constructor gets done with its work.

// superclass Person
class Person {
    Person() {
        System.out.println("Person class Constructor");
    }
}

// subclass Student extending the Person class
class Student extends Person {
    Student() {
        // invoke or call parent class constructor
        super();
        System.out.println("Student class Constructor");
    }
}

// Driver Program
class Test {
    public static void main(String[] args) {
        Student s = new Student();
    }
}

Output

Person class Constructor

Student class Constructor

3. Super use case with Variables

This situation occurs when both the base and derived classes have identical data members which is causing vagueness for JVM.

Example

Imagine there is a child named ‘Ravi’ and the parent also has the same name. We would normally say ‘Parent Ravi’ to call the parent. It is as same as using super.maxSpeed.

// Super keyword with variable 

// Base class Vehicle
class Vehicle {
    int maxSpeed = 120;
}

// Subclass Car extending Vehicle
class Car extends Vehicle {
    int maxSpeed = 180;

    void display() {
        // print maxSpeed from the Vehicle class using super
        System.out.println("Maximum Speed: " + super.maxSpeed);
    }
}

// Driver Program
class Test {
    public static void main(String[] args) {
        Car small = new Car();
        small.display();
    }
}

Advantages of the Java Super Keyword

Here are a few advantages of the Java super keyword-

  • The super keyword enables subclasses to inherit functionality from their parent classes. It allows subclasses to override methods while still accessing fields and methods from the parent class. This makes the code more flexible and maintainable.
  • Methods and fields of the parent class can be accessed directly without redefining them in the subclass using Super.
  • Super supports abstraction and encapsulation. This allows subclasses to focus on their specific tasks while the parent class handles general functionality.

Disadvantages of Java Super Keyword

Here are a few disadvantages of the Java super keyword-

  • The super keyword can only be used in the context of inheritance. It has no use in classes that do not extend another class.
  • super cannot be used in static methods or static blocks because it refers to instance-specific members of the parent class.
  • In complex inheritance hierarchies, using super might lead to confusion about which parent class member is being accessed.

Java this vs super vs this() vs super() - A Quick Comparison Table

Java super is not the only keyword you can use. There are so many of them. Let's explore a comparison between some of the best ones you can use:

Feature / Aspect this super this() super()
Refers to Current object Parent (superclass) object Current class constructor Parent class constructor
Used For Accessing current class variables & methods Accessing parent class variables & methods Calling another constructor in the same class Calling a constructor from the parent class
Where Used? Inside any non-static method Inside any non-static method Inside the constructor only Inside the constructor only
Must be the first statement? No No Yes Yes
Constructor Chaining No No Chains constructors within the same class Chains constructors to the parent class
Access Modifiers Affected? No Can access protected parent members No impact Parent constructor must be accessible
Implicit call? Not called automatically Not called automatically No (used explicitly) Yes, the compiler adds super() if not written
Can both appear in the same constructor? Yes Yes ❌ Cannot be used with super() ❌ Cannot be used with this()
Static Context? ❌ Not allowed ❌ Not allowed ❌ Not allowed ❌ Not allowed
Common Use Cases Resolve local variable conflicts Call overridden parent method; access parent variable Reduce code duplication in constructors Ensure parent object setup before child

Common Mistakes Developers Make with super

Even though the super keyword looks simple, developers often misuse it in real projects. Understanding these mistakes helps avoid compilation errors and logical bugs.

1. Forgetting super() When Parent Has No Default Constructor

If the parent class defines only parameterized constructors, the compiler does NOT add super() automatically.

Example problem:

class Parent {
    Parent(int x) {}
}

class Child extends Parent {
    Child() {
        // Compilation error
    }
}

Fix:

class Child extends Parent {
    Child() {
        super(10);
    }
}

If not handled properly, your code will fail to compile.

2. Using super in Static Context

You cannot use super inside static methods or static blocks.

static void test() {
    super.method(); // Compilation error
}

Reason: super refers to instance-level parent members. Static methods belong to the class, not the object.

3. Confusing super.method() with Polymorphism

Many beginners think super.method() follows runtime polymorphism. It does NOT.

Normal overridden method call:

parentRef.method(); // Runtime polymorphism

Using super:

super.method(); // Compile-time binding

super bypasses dynamic dispatch and directly calls the parent implementation. This distinction is extremely important in interviews and enterprise debugging.

Conclusion

It is safe to conclude that the super keyword is an important tool to bridge the gap between subclasses and their parent classes. It allows efficient code reuse, constructor chaining, method overriding and making inheritance more manageable. Developers must understand this concept effectively so that they can write clearer object-oriented code.

Read Related Articles

FAQs

Q1. Does super allow access to grandparent class members directly?

Super only provides access to the parent class, as it cannot directly reach the grandparent class members.

Q2. Is it mandatory to use super() in a subclass constructor?

It is not mandatory as Java automatically calls the parent’s no-argument constructor if not used directly.

Q3. What happens if super () is not the first statement in a constructor?

The code will fail to compile because super () must be the first line in a subclass constructor.

Q4. Why should freshers learn the super keyword in Java?

Freshers should learn super because it is important for understanding inheritance and how parent and child classes work together.

About the Author
Author Nehal Sharma
About the Author

Nehal Sharma is a skilled Data Analyst with expertise in Java, mobile development, and data analytics. She transforms complex data into actionable insights and has experience in business intelligence, data science, and Salesforce. She also simplifies technical concepts into clear, engaging content for learners and professionals.

Drop Us a Query
Fields marked * are mandatory
×

Your Shopping Cart


Your shopping cart is empty.