Runtime Polymorphism in Java is achieved by Method overriding in which a child class overrides a method in its parent. An overridden method is essentially hidden in the parent class, and is not invoked unless the child class uses the super keyword within the overriding method.
How do you achieve runtime polymorphism?
Runtime polymorphism is achieved through Method Overriding. Method Overriding is done when a child or a subclass has a method with the same name, parameters and return type as the parent or the superclass, then that function overrides the function in the superclass.
How will you achieve the runtime polymorphism in Java explain with code?
So polymorphism means many forms. There are two types of polymorphism in Java: compile-time polymorphism and runtime polymorphism. We can perform polymorphism in java by method overloading and method overriding. If you overload a static method in Java, it is the example of compile time polymorphism.