Polymorphism is the ability of an object to take on many forms. That is, at compile time, Java object will be in reference type but at runtime, it will be in runtime type (object type).

Polymorphism in OOP occurs when a super type references a sub type object.

All Java objects are considered to be polymorphic as they share more than one IS-A relationship (at least all objects will pass the IS-A test…