Dynamic polymorphism

Dynamic polymorphism, also known as runtime polymorphism, is a feature of Java in which the appropriate method to be executed is determined at runtime based on the actual object that the method is called on, instead of the type of the reference variable. This is achieved through method overriding.

Method overriding is the ability to define a method in a subclass that has the same signature (name, return type, and parameter types) as a method in the superclass. When the method is called on an object of the subclass, the method in the subclass is executed, even if the reference variable is of the superclass type.