Override a method by adding to the superclass's result.
The cleanest reuse pattern: ask the superclass for its answer, then extend it with subclass-specific logic.
One of the most common override patterns in AP CSA: a subclass overrides a method that returns a value, calls super.method() to get the parent's result, and then adds to or modifies that result before returning.
This pattern keeps subclass code DRY — you reuse the superclass logic instead of duplicating it — and remains correct even if the superclass implementation later changes.
On the AP exam, this is the dominant inheritance pattern in FRQ #3 and #4 of inheritance-style problems.
Call super.method(); modify the returned value.
Reuse the parent's logic; add the subclass's twist.
The template
public class Subclass extends Superclass {
@Override
public ReturnType method(args) {
ReturnType base = super.method(args);
// modify or extend base
return base + subclassExtra;
}
}
Concrete example
public class Employee {
private double base;
public Employee(double base) { this.base = base; }
public double getSalary() { return base; }
}
public class Manager extends Employee {
private double bonus;
public Manager(double base, double bonus) {
super(base);
this.bonus = bonus;
}
@Override
public double getSalary() {
return super.getSalary() + bonus;
}
}
Manager.getSalary() reuses the Employee logic for the base salary and adds the manager-specific bonus. If the Employee class later adds tax handling, the Manager picks it up automatically.
Why not just access fields directly?
In AP CSA, superclass instance variables are private — the subclass cannot read them directly. super.getSalary() goes through the public accessor and respects encapsulation.
Vocabulary for additive overrides.
Used in inheritance FRQs.
- Override — a subclass method that replaces an inherited one.
- super.method() — call to the superclass version of the method.
- Additive override — override that builds on the superclass's result.
- @Override — annotation marking a method as overriding a parent.
- Encapsulation — accessing fields through accessors rather than directly.
- Reuse — keeping superclass logic available in the subclass.
How additive overrides are tested.
Calling super and respecting encapsulation are the dominant rubric items.
What FRQ graders check:
- Call
super.method()rather than duplicating logic. - Exact return type match with superclass signature.
- Modify the result based on subclass fields.
- Don't access private superclass fields directly. Use accessors.
MCQ patterns: trace the return value when called on a subclass; identify which version of the method runs.
Trace a Manager's salary calculation.
Inheritance flow + bonus addition.
Problem. Using the Employee/Manager classes above, what does m.getSalary() return when m = new Manager(50000, 10000)?
Step 1. Constructor: super(50000) sets base = 50000; then bonus = 10000.
Step 2. m.getSalary() calls the Manager version.
Step 3. Inside: super.getSalary() returns 50000.
Step 4. Add bonus: 50000 + 10000 = 60000.
Answer: 60000.
Why this matters. If Employee's getSalary() later added a tax adjustment, the Manager would automatically incorporate it — that's the value of additive overrides over copy-paste.
Additive-override pitfalls.
Most break encapsulation or duplicate logic.
- Accessing the superclass field directly.
this.basedoesn't compile ifbaseis private in Employee. - Duplicating the superclass logic. Copy-paste breaks DRY and stays broken if the parent changes.
- Forgetting
super.getSalary() + bonuscalls the Manager method again — infinite recursion. - Wrong return type. Must match the superclass signature exactly.
- Forgetting to call super in the constructor. Required when the superclass has no no-arg constructor.
Additive override at a glance.
Three-line pattern.
Additive Override Reference
AP Quick Reference| Step | Action | AP Tip |
|---|---|---|
| 1 | Call super.method() | Reuses parent logic. |
| 2 | Compute subclass extra | Using subclass fields. |
| 3 | Combine and return | Match parent's return type. |
| Encapsulation | Don't touch private fields | Use accessors. |
How to master additive overrides.
Use super; never duplicate.
- MCQ Practice — for each option, check whether
super.method()is called. Duplicated logic is a red flag. - Java Lab — build Employee/Manager, Vehicle/Truck. Override accessors that add subclass fields.
- FRQ Practice — write the three-line pattern: super, add, return.
Practice — attempt these now.
AP-style assessments aligned to this lesson. Time them.
AP CSA Unit 08 Topic 01 Override Adding to Superclass Result FRQ Practice
AP-style topic practice assessment