Recall & Review
beginner
What is runtime polymorphism in Java?
Runtime polymorphism is when a call to an overridden method is resolved at runtime, allowing a subclass to provide a specific implementation that is used instead of the superclass method.Click to reveal answer
beginner
How does Java achieve runtime polymorphism?
Java uses method overriding and dynamic method dispatch to achieve runtime polymorphism. The JVM decides at runtime which method to call based on the object's actual type.
Click to reveal answer
beginner
What is method overriding?
Method overriding happens when a subclass provides its own version of a method already defined in its superclass with the same signature.Click to reveal answer
intermediate
Why can't runtime polymorphism happen with static methods?
Static methods belong to the class, not instances, so they are resolved at compile time, not runtime. Therefore, they cannot be overridden or used for runtime polymorphism.
Click to reveal answer
intermediate
Explain dynamic method dispatch with a simple example.
Dynamic method dispatch means the JVM calls the overridden method of the actual object type, not the reference type. For example, if a superclass reference points to a subclass object, the subclass method runs at runtime.Click to reveal answer
Which feature allows Java to decide which overridden method to call at runtime?
✗ Incorrect
Dynamic method dispatch is the process Java uses to call the correct overridden method at runtime.
What must be true for runtime polymorphism to occur?
✗ Incorrect
Only overridden methods can be resolved at runtime for polymorphism.
Can runtime polymorphism happen with constructors?
✗ Incorrect
Constructors are not inherited and cannot be overridden, so runtime polymorphism does not apply.
What keyword is used to override a method in Java?
✗ Incorrect
The @Override annotation helps indicate a method is overriding a superclass method.
Which of these is NOT a benefit of runtime polymorphism?
✗ Incorrect
Runtime polymorphism uses runtime binding, which can be slower than compile-time binding.
Describe runtime polymorphism and how Java uses it with method overriding.
Think about how Java decides which method to run when a superclass reference points to a subclass object.
You got /4 concepts.
Explain why static methods cannot participate in runtime polymorphism.
Consider when static methods are linked compared to instance methods.
You got /4 concepts.