this() Constructor Call vs super() Constructor Call
this() vs super() constructor calls explained — same-class delegation vs parent delegation, first-statement rule — with Java examples.
Expected Interview Answer
`this(...)` invokes another constructor of the same class, while `super(...)` invokes a constructor of the immediate parent class, and both must appear as the very first statement of a constructor if used at all.
A `this(...)` call is used to delegate between overloaded constructors within one class, so common initialization logic lives in a single canonical constructor. A `super(...)` call is used to ensure the inherited (parent) portion of an object’s state is initialized before the subclass adds its own — this reflects that a subclass constructor should never run before its parent constructor has completed. Because only one first statement exists, a constructor may use `this(...)` or `super(...)`, never both, and never neither in a meaningful sense — if omitted entirely, Java inserts an implicit `super()` on your behalf. Chaining through `this(...)` eventually still bottoms out at a `super(...)` call somewhere in the chain, since every object’s construction must reach back to `Object`’s constructor.
- Clear separation between same-class delegation and parent-class delegation
- Guarantees parent state exists before subclass fields are set
- Prevents duplicated initialization logic across overloaded constructors
- Keeps the compile-time construction order explicit and predictable
AI Mentor Explanation
Calling for a specific pre-match drill from the team’s own drill list is like this(...) — you stay within your own team’s playbook and just pick a different, more detailed drill. Requesting the national academy’s mandatory baseline fitness protocol before your team drill can even start is like super(...) — you’re reaching up to a governing, higher-level process that must run first. A player can invoke one or the other before training truly begins, never both baseline requests at once.
Step-by-Step Explanation
Step 1
Identify same-class delegation
Use this(...) when one constructor should reuse another constructor in the same class.
Step 2
Identify parent delegation
Use super(...) when the subclass must initialize inherited state defined by the parent.
Step 3
Place it first
Whichever is used must be the first statement in the constructor body.
Step 4
Remember the implicit default
If neither is written, Java inserts an implicit no-arg super() call automatically.
What Interviewer Expects
- Precise distinction: same-class (this) vs parent-class (super) delegation
- Knowledge that only one can appear, and only as the first statement
- Understanding of the implicit super() when neither is written
- Awareness that a this(...) chain still eventually reaches a super(...) call
Common Mistakes
- Thinking this(...) and super(...) can be combined in one constructor
- Believing super(...) is optional to call correctly at any point in the body
- Confusing this(...) constructor chaining with the this keyword used for field references
- Assuming a class without extends has no implicit super() call at all (it still calls Object())
Best Answer (HR Friendly)
“this(...) calls another constructor in the same class, useful when you want one constructor to reuse a fuller one instead of repeating code. super(...) calls the parent class constructor, which is how you make sure the inherited part of the object gets set up first. You can only use one of them, and it always has to be the first line of the constructor.”
Code Example
class Employee {
String name;
Employee(String name) {
this.name = name;
}
}
class Manager extends Employee {
int teamSize;
Manager(String name) {
this(name, 0); // this(): same-class delegation
}
Manager(String name, int teamSize) {
super(name); // super(): parent-class delegation
this.teamSize = teamSize;
}
}Follow-up Questions
- What compile error occurs if you try to use both this() and super()?
- Does a this(...) chain still eventually call super()?
- What happens when a class has no explicit extends clause?
- Can you call an instance method before super() completes?
MCQ Practice
1. this(...) inside a constructor calls?
this(...) delegates to a different constructor of the same class.
2. super(...) inside a constructor calls?
super(...) invokes a constructor of the direct superclass.
3. What happens if neither this(...) nor super(...) is written explicitly?
The compiler automatically adds an implicit super() call when no explicit chaining call exists.
Flash Cards
this(...) targets? — A constructor in the same class.
super(...) targets? — A constructor in the immediate parent class.
Can both be used together? — No — only one chaining call is allowed per constructor.
Default behavior if omitted? — An implicit no-arg super() call is inserted automatically.