Unit 3 Cycle 2 Day 2: Error: Missing super() Call

Unit 3 Advanced (Cycle 2) Day 2 of 28 Advanced

Error: Missing super() Call

Section 3.14 — The super Keyword

Key Concept

When a subclass constructor does not explicitly call super(), Java inserts super() (the no-arg version) automatically. If the superclass does not have a no-argument constructor (because it defined only parameterized constructors), this implicit call fails and the code does not compile. This is one of the most common inheritance compilation errors. The fix is to either add a no-argument constructor to the superclass or have the subclass explicitly call a valid superclass constructor with super(args).

Consider the following classes.

public class Shape { private String color; public Shape(String c) { color = c; } public String getColor() { return color; } } public class Circle extends Shape { private double radius; public Circle(double r) { radius = r; } }

What happens when this code is compiled?

Answer: (B) Compile error: Circle constructor must call super().

Shape has no no-arg constructor (only a one-arg constructor). Circle's constructor does not call super(), so Java tries to insert super() (no args) automatically. This fails because Shape requires a String argument.

Why Not the Others?

(A) The compiler cannot find a matching no-arg constructor in Shape.

(C) This is caught at compile time, not runtime.

(D) private fields are correct for encapsulation. This is not the issue.

Common Mistake

If you do not write super(...) as the first line of a subclass constructor, Java automatically inserts super() (no args). If the parent has no no-arg constructor, this causes a compile error.

AP Exam Tip

Always check: does the parent class have a no-arg constructor? If not, the subclass MUST explicitly call super(args).

Review this topic: Section 3.14 — The super Keyword • Unit 3 Study Guide

More Practice

Back to blog

Leave a comment

Please note, comments need to be approved before they are published.