The super Keyword in Java
The super keyword in Java lets a child class reach its parent class: to call the
parent's constructor, to reuse a method it has overridden, or to read a hidden field. If
this means "me", super means "the parent part of me".
What is super in Java?
When you create an object of a child class, it contains a "parent layer" built from the parent class. Think of a
house extension: the new rooms are yours, but the original house is still there underneath. super
lets the child's code reach that original layer. It only makes sense with
inheritance.
4 ways to use super
super(...)
Calls the parent constructor, so the parent part of the object is set up first.
Manager(String name, int teamSize) {
super(name); // let Employee set the name
this.teamSize = teamSize;
} super.method()
Calls the parent's version of a method you overrode, so you can extend it instead of rewriting it.
@Override
String describe() {
return super.describe() + ", manages " + teamSize;
} super.field
Reaches a parent field that a child field with the same name hides. Rare, and usually a sign the names should differ.
class Parent { String label = "parent"; }
class Child extends Parent {
String label = "child";
String both() { return label + "/" + super.label; }
} Iface.super.m()
Calls a specific interface's default method, needed when two interfaces provide the same one.
public String start() {
return Printer.super.start();
} A complete example: Employee and Manager
class Employee {
protected final String name;
Employee(String name) {
this.name = name;
}
String describe() {
return name + " is an employee";
}
}
class Manager extends Employee {
private final int teamSize;
Manager(String name, int teamSize) {
super(name); // 1. parent sets up 'name'
this.teamSize = teamSize; // 2. child sets up its own field
}
@Override
String describe() {
return super.describe() // 3. reuse the parent's text...
+ " who manages " + teamSize; // ...and add to it
}
}
System.out.println(new Manager("Asha", 6).describe()); Asha is an employee who manages 6
super(name)— runsEmployee's constructor so the inheritednamefield is set properly.super.describe()— callsEmployee's version. Writing justdescribe()here would callManager's own method again and loop forever (aStackOverflowError).
How does super() work in constructors?
What if I don't write super(...) at all?
Java quietly inserts super();, a call to the parent's no-argument constructor. If the
parent doesn't have one, as with Employee above, which only has Employee(String),
you get a compile error and must call super(...) yourself.
class Intern extends Employee {
Intern() {
// ✘ compile error: constructor Employee in class Employee cannot be applied to given types
}
} Constructors always run from the top down
Every constructor first hands off to its parent, all the way up to Object. Then they finish in order from parent to child:
class A { A() { System.out.println("A built"); } }
class B extends A { B() { System.out.println("B built"); } } // implicit super()
class C extends B { C() { System.out.println("C built"); } } // implicit super()
new C(); A built B built C built
Why the parent finishes first
new C()startsC(), which immediately callssuper()→B()B()callssuper()→A(), which callssuper()→Object()- Each constructor's own code then runs on the way back down: A, then B, then C.
A child can safely rely on its parent's fields being ready, because the parent part is always built first.
Rules for using super
| Rule | Why |
|---|---|
super(...) only inside a constructor | It's part of building the object. |
Use super(...) or this(...), not both | Each constructor hands off to exactly one other. |
Before Java 25, super(...) must be the first statement | Since Java 25 (JEP 513) you may validate arguments first, without touching the object. |
No super in static code | Static code has no current object. |
No super.super.method() | You can only reach your direct parent. |
super vs this: what's the difference?
this | super | |
|---|---|---|
| Refers to | The current object (child's view) | The parent-class part of the current object |
| Constructor call | this(...) — same class | super(...) — parent class |
| Method call | this.m() — child's version (if overridden) | super.m() — parent's version |
Quick recap
super(...)calls the parent constructor; Java insertssuper()if you don't.super.method()runs the parent's version of an overridden method.- Constructors run parent-first, all the way from
Objectdown. supercan't be used in static code, andsuper.superisn't allowed.
What's next?
Learn what happens when something belongs to the class instead of an object, in the
static keyword guide, or review this.
Frequently Asked Questions
What is the super keyword in Java?
super is a reference to the parent class part of the current object. You use it to call the parent's constructor with super(...), to call the parent's version of an overridden method with super.method(), or to reach a parent field hidden by a child field.
Is super() called automatically in Java?
Yes. If a constructor doesn't call this(...) or super(...) itself, Java inserts super() with no arguments for you. If the parent class has no no-argument constructor, that automatic call fails and you must write super(...) with arguments.
Can I use super in a static method?
No. Like this, super refers to the current object, and static methods don't have one. Using super inside a static method or static block is a compile error.
What is the difference between super() and this()?
super(...) calls a constructor of the parent class. this(...) calls another constructor of the same class. A constructor can use one or the other, but not both, because each constructor must hand off to exactly one other constructor.
Can I call a grandparent's method with super.super?
No. Java doesn't allow super.super.method(). You can only reach the direct parent. If the grandparent's behaviour is needed, the parent class should expose it through its own method.