Skip to content
UniCircle
EasyConceptualOOP concepts

The this and super keywords

Question JAVA-OOP-011

What are this and super used for? Give examples of each.

Show the explanation

this refers to the current object; super refers to the parent-class part of the current object.

Uses of this: telling a field apart from a parameter with the same name, calling another constructor of the same class (this(...)), and passing the current object somewhere.

Uses of super: calling a parent constructor (super(...)) and calling the parent's version of an overridden method (super.method()).

Java
class Vehicle {
    protected String reg;
    Vehicle(String reg) { this.reg = reg; }
    String describe() { return "Vehicle " + reg; }
}
class Bus extends Vehicle {
    private int seats;
    Bus(String reg, int seats) { super(reg); this.seats = seats; }
    Bus(String reg) { this(reg, 40); }                       // constructor chaining
    @Override String describe() { return super.describe() + " with " + seats + " seats"; }
}

A call to this(...) or super(...) must be the first statement of a constructor, so a constructor can use one or the other, not both. Neither keyword can be used in a static context.

Original UniCircle question. Last reviewed 22 Oct 2026.