01
Overview

Extending the superclass's String output.

The classic toString pattern: keep what the parent said, then append the subclass's own details.

One of the most common override forms in AP CSA is a toString() that extends the parent's text rather than replacing it. The subclass calls super.toString(), then concatenates its own information.

The same approach applies to any method returning a String — descriptions, summaries, labels — where the subclass should add detail without losing the parent's wording.

On the AP exam, this pattern appears in inheritance FRQs that ask for a hierarchical String representation.

02
Core Concept

Append the subclass's details to the parent's string.

Concatenation handles the combination.

The template

@Override
public String toString() {
    return super.toString() + ", subclassField=" + subclassField;
}

Concrete example

public class Vehicle {
    private String make;
    public Vehicle(String m) { make = m; }
    public String toString() {
        return "Make: " + make;
    }
}

public class Car extends Vehicle {
    private int doors;
    public Car(String m, int d) { super(m); doors = d; }
    @Override
    public String toString() {
        return super.toString() + ", Doors: " + doors;
    }
}

new Car("Toyota", 4).toString() returns "Make: Toyota, Doors: 4".

Hierarchical chains

If a class further extends Car (say, SportsCar), the chain continues:

@Override
public String toString() {
    return super.toString() + ", Top Speed: " + topSpeed;
}

Each level adds its own piece. The full string reflects every ancestor.

03
Key Vocabulary

String-extension vocabulary.

Used in hierarchical-output problems.

Vocabulary
  • toString — method returning a String representation of an object.
  • Concatenation — joining Strings with +.
  • Hierarchical output — string that reflects multiple inheritance levels.
  • Append — adding to the end of an existing String.
  • String chain — each level adds its piece.
04
AP Exam Focus

How String-extending overrides are tested.

Calling super and exact format dominate.

Exam Focus
  • Use super.toString(). Don't duplicate parent's output.
  • Match the format exactly. Punctuation and spacing count.
  • Cast or call toString on fields if needed. But primitives auto-convert.
  • Don't call this.toString(). Recursion trap.
05
Worked Example

Three-level extension chain.

Trace each toString.

Worked Example AP-style reasoning

Setup. Vehicle → Car → SportsCar. Each toString appends.

Vehicle.toString(): "Make: Honda"

Car.toString(): super.toString() + ", Doors: 2" → "Make: Honda, Doors: 2"

SportsCar.toString(): super.toString() + ", Top Speed: 250" → "Make: Honda, Doors: 2, Top Speed: 250"

Why this matters. Each level extends the previous String. The chain naturally produces a complete description.

06
Common Mistakes

Output-extension pitfalls.

Format and recursion are the top issues.

Watch Out
  • Duplicating the parent's text. Use super; don't copy.
  • Missing comma or space. AP rubrics check format.
  • Calling this.toString() instead of super. Infinite recursion.
  • Putting the addition in the wrong place. Pre- vs post-append matters for readability.
07
Reference Table

Extending output at a glance.

Three pieces; one line.

Output Extension Reference

AP Quick Reference
PieceSourceAP Tip
Parent textsuper.toString()Reuses parent logic.
SeparatorLiteral (e.g., ", ")Match rubric format.
Subclass detailSubclass fieldsVia accessors or direct.
08
Practice Tip

How to master output extension.

Trace each level; format precisely.

Practice Strategy
  • MCQ Practice — for each toString chain, write out each level's contribution before concatenating.
  • Java Lab — build Vehicle/Car/SportsCar and verify the chained output matches expected format.
  • FRQ Practice — copy the rubric's format exactly: comma, space, label.
09
Section · 09

Practice — attempt these now.

AP-style assessments aligned to this lesson. Time them.

FRQ Practice 30 min 18 marks Pending

AP CSA Unit 08 Topic 04 Overriding That Extends Superclass Output FRQ Practice

AP-style topic practice assessment

Start