Unit 3 Cycle 2 Day 6: Overriding vs Overloading
Share
Overriding vs Overloading
Section 3.13 — Overriding Methods
Key Concept
Overriding requires the exact same method signature (name and parameter types), while overloading uses the same name with different parameter types. A method with a different parameter list is an overload, not an override, even if the name matches. The AP exam creates traps where a method appears to override but actually overloads due to a subtle parameter difference (like int vs double or adding an extra parameter). The superclass version still runs for calls that match the original signature.
Consider the following classes.
Which statement is correct about the Child class?
Answer: (B) greet(String) overloads greet() from Parent.
Child's greet(String) has a different parameter list than Parent's greet(). Different parameters = overloading, not overriding. Child has BOTH methods: greet() inherited from Parent and greet(String) defined in Child.
Why Not the Others?
(A) Overriding requires the exact same method signature (name and parameters). Different parameters = overloading.
(C) The inherited greet() is still accessible. Overloading adds a method, it does not replace one.
(D) Overloading is valid. The code compiles successfully.
Common Mistake
Overriding: same name AND same parameters in subclass. Overloading: same name but DIFFERENT parameters. Overloading adds a new version; overriding replaces the parent version.
AP Exam Tip
Override = same signature, different class (subclass replaces parent). Overload = same name, different parameters (can be in same class). The AP exam tests this distinction directly.