Advance-Java Types of Polymorphism #16

Опубликовано: 16 Март 2026
на канале: King of Techniques
54
9

#polymorphism #java #javaoops #oops
‪@kingoftechniques6864‬

Polymorphism means ‘many forms’. In OOP, polymorphism means a type can point to different object at different time. In other words, the actual object to which a reference type refers, can be determined at runtime.
In Java, polymorphism is based on inheritance and overriding. So if you absorbed my lessons about inheritance and overriding the following tutorials:

Polymorphism is a robust feature of OOP. It increases the reusability, flexibility and extensibility of code. Take the above example for instance:
Reusability: the teach() method can be re-used for different kinds of objects as long as they are sub types of the Animal interface.
Flexibility: the actual object can be determined at runtime which allows the code run more flexibly.
Extensibility: when we want to add a new kind of Animal, e.g. Snake, we just pass an object of Snake into the teach() method without any modification.
That’s all about polymorphism I want to share with you today.

Types of Polymorphisms - Ad-hoc, Inclusion, Parametric & Coercion. Here we will see different types of polymorphism. The types are −. The Ad-Hoc polymorphism is called as overloading. This allows function with same name to act in different manner for different types. The function and the operator both can be overloaded.