Java this and super Keywords: quick revision, 15 bites

All 15 revision bites from this kit, free and with no sign-up.

this vs super: Two References, Two Targets

One points inward, one points upward.

`this` refers to the **current object**; `super` refers to the **immediate parent class** of the current object.

Takeaway. Use `this` to talk about yourself; use `super` to talk to your parent.

What Exactly Is 'this'?

The object's self-portrait.

Takeaway. `this` is how an object refers to itself inside its own methods and constructors.

What Exactly Is 'super'?

The parent's doorway.

Takeaway. `super` lets a subclass access members and constructors of its direct parent.

Resolving Variable Shadowing with 'this'

Same name, different scope.

When a constructor parameter has the same name as an instance field, `this.field` disambiguates.

Takeaway. `this.field` always refers to the instance variable, not the local parameter.

Accessing Hidden Parent Fields with 'super'

When the child hides the parent's field.

If a subclass declares a field with the same name as a parent field, `super.field` accesses the parent's version.

Takeaway. `super.x` bypasses the child's shadowing field and reads the parent's field.

Calling Overridden Methods with 'super'

Reuse the parent's logic, then extend it.

When a subclass overrides a method, `super.method()` invokes the parent's original implementation.

Takeaway. `super.method()` lets you call the overridden parent method from the child.

Constructor Chaining with this() and super()

Constructors calling constructors.

`this(...)` calls another constructor of the **same class**; `super(...)` calls a constructor of the **parent class**. Both must be the first statement in a constructor.

Takeaway. Constructor chaining avoids code duplication and ensures proper initialization order.

this() Constructor Chaining in Action

One class, many constructors, no repetition.

Takeaway. `this(...)` lets a no-arg constructor delegate to a parameterized one.

super() Constructor Chaining in Action

Initialize the parent first.

Takeaway. `super(...)` ensures the parent's fields are initialized before the child's.

this() and super() Must Be First

Order matters in constructors.

Takeaway. Constructor chaining calls must be the first statement — no exceptions.

Can't Use Both this() and super()

Pick one, not both.

Takeaway. Only one constructor delegation call is allowed per constructor.

Default super() Is Inserted Automatically

Java does it for you.

If a constructor does not explicitly call `this(...)` or `super(...)`, the Java compiler automatically inserts a no-argument `super()` call — provided the parent has an accessible no-arg constructor.

Takeaway. Silent `super()` insertion means the parent's no-arg constructor runs first by default.

super() Fails If Parent Has No No-Arg Constructor

Missing parent constructor breaks compilation.

Takeaway. Always ensure the parent has a no-arg constructor or call `super(...)` explicitly.

Returning the Current Object with 'this'

Fluent APIs start here.

Returning `this` from a method enables **method chaining**, a common pattern in builders and fluent APIs.

Takeaway. `return this;` is the backbone of fluent interfaces and builder patterns.

Exam Favorite: this vs super Quick Recall

Two keywords, four uses.

Takeaway. Memorize the four usage pairs — most exam questions test exactly these.

Make your own

Your notes can be a kit like these

Every kit here was made from real study material. Point Veda at a chapter, a PDF, a photo or a link and get notes, flashcards, practice MCQs, games and a scored test — free, in 42 languages.

  • Chapter notes
  • Flashcards
  • Practice MCQs
  • Scored tests
  • Exam prep

Get Veda free See what students get

Free to start · No ads · Works in 42 languages