Challenge 2: Dynamic Dispatch Through a Shape-Typed Variable — Possible Solution ==================================================================== DispatchDemo.java: public class DispatchDemo { public static void main(String[] args) { Shape s = new Circle(2.0); System.out.println(s.area()); // Even though `s` is DECLARED as type Shape, calling s.area() // runs Circle's overridden version, not Shape's own // 0.0-returning version. This is dynamic dispatch: Java looks // at the object's ACTUAL runtime type (Circle) to decide which // area() to run, not the variable's declared compile-time type // (Shape). // // This happens automatically because every Java instance // method is virtual by default -- no keyword needed to opt in. // In C++ (cpp1-7), this same behavior would require area() to // have been explicitly marked `virtual` in the base class; // without that keyword, C++ would statically bind to Shape's // own area() based on the declared type alone, ignoring the // real object underneath. } } Output: 12.566370614359172 WHY THIS WORKS AS AN ANSWER ------------------------------ This demonstrates dynamic dispatch happening through a base-typed variable with zero extra syntax, and explains it using the chapter's own stated contrast -- Java's virtual-by-default instance methods versus C++'s opt-in virtual keyword, which would change this exact example's outcome if it were written in C++ without that keyword.