AP CSA Unit 3 Day 4: Method Overriding
Share
Unit 3, Classes & Objects • Cycle 2
Day 4 Advanced Practice • Harder Difficulty
Focus: Method Overriding
Hard
Method Overriding
Advanced Practice Question
Format: Method Overriding
What is the output?
What is the output?
public class Parent {
public void display() {
System.out.print("A");
}
}
public class Child extends Parent {
public void display() {
System.out.print("B");
}
}
// In another class:
Parent p = new Child();
p.display();
Difficulty: Hard |
Topic: Method Overriding |
Cycle: 2 (Advanced)
Why This Answer?
Even though p is declared as Parent, it references a Child object. At runtime, Java uses dynamic binding and calls Child's display() method.
Common Mistake
Watch Out!
Thinking the declared type (Parent) determines which method runs.
AP Exam Strategy
Runtime type (what the object IS) determines which overridden method executes.
Master This Topic
This Cycle 2 HARD question tests method overriding. Review Unit 3 concepts to build mastery of classes & objects.
- Understanding method overriding
- Tracing code execution accurately
- Avoiding common pitfalls
Ready for More Challenges?
Cycle 2 questions prepare you for the hardest AP CSA exam questions.
Study Games Practice FRQs