Overriding enables polymorphism by allowing method calls on superclass references to execute subclass methods.
Polymorphism in Java is achieved through method overriding. It allows objects of different classes to be treated as objects of a common superclass. When a method is called on a superclass reference, Java uses the overridden method in the subclass, allowing for dynamic method dispatch. For instance, if you have a `Product` reference that points to a `DiscountedProduct` object, calling `getPrice()` will execute the `DiscountedProduct`'s method, demonstrating polymorphic behavior.
Additional Notes
How does method overriding relate to the concept of polymorphism?