Compile-time checks reference type; runtime uses actual object type.
At compile time, Java checks that methods are accessible based on the reference type, ensuring no undefined methods are called. However, at runtime, the actual object's type determines which method implementation is executed. This separation means you can call overridden methods not visible at compile-time. For example, a superclass reference `Product` pointing to a `Book` object will only allow access to `Product` methods, but at runtime, `Book`'s methods are executed if overridden.
Additional Notes
Explain compile-time access vs. runtime dispatch?
Track: Java
Topic: Core Java
Focus: Upcasting and Dynamic Dispatch
Topics:Core JavaJavaUpcasting and Dynamic Dispatch