Unit 3 Cycle 2 Day 28: Comprehensive Unit 3 Final Review
Share
Comprehensive Unit 3 Final Review
Section Mixed — Review: All Unit 3
Key Concept
This Unit 3 final review covers all class design and inheritance topics at exam-level difficulty. Unit 3 has the highest weight on the AP CSA exam at 22-28% of questions. The most critical topics are: polymorphic method dispatch (the compile-time vs runtime type distinction), constructor chaining with super(), correctly overriding versus accidentally overloading methods, encapsulation with private fields and public methods, and the this keyword for disambiguation and self-reference. Free-response questions almost always involve Unit 3 concepts.
Consider the following hierarchy.
What does System.out.println(new Circle(10)); print?
Answer: (B) Area=314.0
println calls toString(). Circle inherits Shape's toString() which calls area(). Dynamic dispatch: Circle's area() runs, returning 3.14*100=314.0. toString returns "Area=314.0".
Why Not the Others?
(A) Shape's area() returns 0, but Circle overrides it. The override runs.
(C) Shape overrides Object's toString(), so the hash format is not used.
(D) toString() prepends "Area=" before the area value.
Common Mistake
This combines toString() inheritance with area() polymorphism. Shape's toString() calls area(), and dynamic dispatch ensures Circle's area() is used.
AP Exam Tip
Combining inherited toString() with overridden helper methods is a classic AP exam pattern. Trace which version of each method runs based on the actual object type.