01
Overview

Combining inherited state with subclass state.

The subclass owns its own field; the override pulls inherited state via super and adds the new field to the result.

When a subclass introduces a new instance variable that contributes to a computation, the cleanest override delegates the inherited part to super.method() and adds the subclass's own field on top.

This keeps each class's responsibilities clean: the parent manages its own fields; the subclass manages its own field plus the combining logic.

On the AP exam, this pattern is the most common version of inheritance FRQ scoring — typically getTotalPay = super.getTotalPay + commission or similar.

02
Core Concept

super for inherited fields; this for subclass fields.

Combine in the override.

Setup

public class Employee {
    private double salary;
    public Employee(double s) { salary = s; }
    public double getTotalPay() { return salary; }
}

public class SalesEmployee extends Employee {
    private double commission;
    public SalesEmployee(double s, double c) {
        super(s);
        commission = c;
    }
    @Override
    public double getTotalPay() {
        return super.getTotalPay() + commission;
    }
}

The Employee class never knew about commission — and doesn't have to. The SalesEmployee adds its own field and combines it in the override.

Why this respects encapsulation

The subclass can't read salary directly because it's private to Employee. But it doesn't need to: super.getTotalPay() returns the value that depends on salary.

Mutators of subclass state

The subclass can add its own setter for commission without affecting the inherited salary handling.

03
Key Vocabulary

Stateful-override vocabulary.

Used in pay, score, and total computations.

Vocabulary
  • Subclass state — instance variables declared in the child class.
  • Inherited state — fields from the parent, accessible via accessors.
  • Stateful override — override that uses both layers of state.
  • Field combination — combining results from each layer.
  • Encapsulation — private fields, public accessors.
04
AP Exam Focus

How stateful overrides are tested.

Calling super and using subclass fields together dominates.

Exam Focus
  • Call super.method() for inherited contribution.
  • Use this.field (or just field) for subclass contribution.
  • Combine appropriately. Add, multiply, concatenate — per spec.
  • Don't access parent's private field directly. Compile error.
05
Worked Example

Total pay for a sales employee.

Two layers; one result.

Worked Example AP-style reasoning

Setup. SalesEmployee from above.

Call: new SalesEmployee(40000, 8000).getTotalPay().

Step 1. super.getTotalPay() returns 40000.

Step 2. Add commission: 40000 + 8000 = 48000.

Answer: 48000.

Why this matters. If Employee later changes getTotalPay to deduct taxes, SalesEmployee automatically inherits that behavior because it delegates via super.

06
Common Mistakes

Stateful-override pitfalls.

Most break encapsulation.

Watch Out
  • Accessing parent's private field directly. this.salary doesn't compile.
  • Forgetting super. Calling getTotalPay() (without super) causes infinite recursion.
  • Returning only the subclass piece. Misses inherited contribution.
  • Wrong sign or operator. Read the rubric — addition vs multiplication matter.
07
Reference Table

Stateful override at a glance.

Three pieces.

Stateful Override Reference

AP Quick Reference
SourceAccessUse
Parent's statesuper.method()Inherited contribution.
Subclass's statethis.fieldNew contribution.
CombinationOperatorPer spec.
08
Practice Tip

How to master stateful overrides.

Two access patterns; one combination.

Practice Strategy
  • MCQ Practice — for each override, verify both super.method() and the subclass field appear.
  • Java Lab — build Employee/SalesEmployee. Test that bonuses combine with base correctly.
  • FRQ Practice — call super for inherited; reference your field for new; combine per spec.
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 08 Stateful Override Adding to Super FRQ Practice

AP-style topic practice assessment

Start