Unit 3 Cycle 1 Day 20: Inheritance: Calling super Methods

Unit 3 Foundation (Cycle 1) Day 20 of 28 Foundation

Inheritance: Calling super Methods

Section 3.14 — The super Keyword

Key Concept

A subclass can call a superclass method using super.methodName(), which is especially useful when overriding a method but wanting to extend rather than replace the superclass behavior. For example, an overridden toString() might return super.toString() + " extra info". Without super., calling toString() from within the override would recursively call itself. The AP exam tests whether super correctly invokes the parent's version versus triggering infinite recursion.

Consider the following classes.

public class Employee { private String name; private double salary; public Employee(String n, double s) { name = n; salary = s; } public double pay() { return salary; } public String toString() { return name; } } public class Manager extends Employee { private double bonus; public Manager(String n, double s, double b) { super(n, s); bonus = b; } public double pay() { return super.pay() + bonus; } }

What does new Manager("Jo", 50000, 10000).pay() return?

Answer: (B) 60000.0

Manager's pay() calls super.pay() which returns salary (50000), then adds bonus (10000). Total: 60000.

Why Not the Others?

(A) 50000 is just the salary without the bonus.

(C) 10000 is just the bonus without the salary.

(D) super.pay() correctly calls Employee's pay() method.

Common Mistake

super.method() calls the parent class version. This lets a subclass extend behavior rather than completely replace it. The Manager adds bonus on top of the base salary.

AP Exam Tip

Using super.method() in an overriding method lets you reuse parent logic and add to it. This is a common AP exam pattern.

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.