this() and super() Cannot Coexist in Same Constructor
Fast recall
Quick revision
Core answer
this() and super() must be the first statement in a constructor, and a constructor can only have one first statement. The compiler rejects any attempt to use both. The solution is constructor delegation: when a constructor calls this(args), the responsibility for calling super() passes to the constructor being delegated to — eventually one constructor in the chain calls super() explicitly or receives the invisible auto-inserted one.Understanding of the first-statement rule and why it is a hard compile-time constraint, not just a style guideline.
Thinking you can work around it by placing one before the other — the compiler strictly enforces that exactly one of them is the very first statement.
Explain the design rationale: ensuring the object is fully initialized before any other code runs, and how constructor delegation resolves the constraint naturally.
Interview-ready guide
Interview answer
The short version is that both this() and super() have to be the first statement in a constructor, and a constructor only has one first statement — so you physically can't have both, and reordering them doesn't help. The reason Java is this strict is initialization safety. Objects get built from the parent down: the parent class has to be fully constructed before any subclass code touches a field, so super() is forced to run first. this() follows the same logic — it hands initialization to another constructor in the same class, so nothing should run before that constructor finishes its work. Both need the first slot for the same reason, and there's only one.
In practice you never really fight this rule, because you use constructor delegation: one primary constructor owns the super() call, and the simpler constructors call this(args) with default values to funnel into it. Think of it as a relay — the baton gets passed with this() until the final constructor calls super() exactly once. And if you write neither, Java quietly inserts a no-arg super() for you, which works fine until the parent has only parameterized constructors — then you're back to writing super(args) yourself.
this() and super() Cannot Coexist in Same Constructor
Direct Answer
Both this() and super() must be the first statement in a constructor, and a constructor can only have one first statement. The compiler rejects any attempt to use both. The solution is constructor delegation: when a constructor calls this(args), the responsibility for calling super() passes to the constructor being delegated to — eventually one constructor in the chain calls super() explicitly or receives the invisible auto-inserted one.
Code Example
public class Customer {
private String name;
private String email;
private String phone;
// The most complete constructor — this one calls super() (inserted by Java)
public Customer(String name, String email, String phone) {
// Java invisibly inserts: super();
this.name = name;
this.email = email;
this.phone = phone;
}
// Simpler constructor — delegates to three-arg via this()
// this() must be the FIRST statement — cannot write anything before it
public Customer(String name, String email) {
this(name, email, null); // chains to the three-arg constructor above
}
// Simplest constructor — delegates to two-arg, which chains further
public Customer(String name) {
this(name, "noemail@example.com"); // chains to two-arg above
}
// ILLEGAL — cannot have both; uncomment to see compile error:
// public Customer(String name) {
// super(); // compile error: super() must be first
// this(name, "", null); // compile error: this() must be first
// // and you cannot have two 'firsts'
// }
}
class PremiumCustomer extends Customer {
private int rewardPoints;
public PremiumCustomer(String name, String email, int rewardPoints) {
super(name, email); // calls Customer(name, email) — must be first
this.rewardPoints = rewardPoints;
}
}
Common Mistakes & Pitfalls
- Thinking you can reorder them to fit both in — there is exactly one first-statement slot per constructor, so order makes no difference; using both is always a compile error.
- Treating it as a style rule you can bend — the compiler enforces it, so the file simply won't build; you cannot ship code that breaks it.
- Assuming a no-arg
super()is always added for you — Java inserts it only when the parent has a no-arg constructor; with a parameterized-only parent you must callsuper(args)yourself. - Slipping a log or null-check before
this()/super()— even one harmless statement ahead of the call breaks the first-statement rule and fails compilation.
Check your understanding
Answer these without looking back at the article.
- What happens if you don't call super() or this() in a constructor?
- Can a constructor have neither this() nor super()?
- How does Java ensure the parent constructor is always called?
Looking for a structured roadmap?
Every module on this page is also part of the full Java backend interview track.