Exams Knowledge Hub

MCQs for Competitive Exams, School & College Exams

Module: | Core Architecture, Basics & Control Flow

Q22: Consider the following statements regarding Method Overriding:

1. Method overriding is a manifestation of runtime polymorphism where a subclass provides a specific implementation for a method already defined in its parent class.
2. The JVM utilizes Dynamic Method Dispatch to determine which version of an overridden method to execute based strictly on the reference variable type, not the object type.
3. For a method to be legitimately overridden, the subclass method must have the exact same name, parameter list, and return type as the parent class method.

Which of the above statements is/are correct?
A
Only 1 and 2
B
Only 1 and 3
C
Only 2 and 3
D
1, 2, and 3
✅ Correct Answer: B
🎯 Quick Answer:
The correct combination is 1 and 3. Statement 2 is incorrect because Dynamic Method Dispatch resolves the method based exclusively on the runtime Object type residing in the Heap, completely ignoring the compile-time reference variable type.
Concept Definition: Method Overriding is a runtime polymorphism mechanism allowing a subclass to inject a highly specialized implementation for a method whose signature is already established in a parent class.
Structural Breakdown: Overriding requires an identical method name, an identical parameter list, and an identical or covariant return type.
The Override annotation is optionally utilized to force the compiler to verify these strict matching conditions.
Historical/Related Context: Overriding is the foundational backbone of framework design.
It allows Java developers to interact with abstract base classes while executing custom logic defined entirely in specialized child classes, a pattern heavily tested in academic environments.
Causal Reasoning: Late binding guarantees extreme architectural flexibility.
A program can maintain an array of generic parent references, but when a method is iterated, the JVM dynamically inspects the Heap memory at that exact millisecond to trigger the specialized child logic.