Polymorphism

Learn about polymorphism and its types.

Overview

The word polymorphism consists of two root words. Poly means many, and morph means shape or form. Polymorphism in object-oriented programming means that an object can take many forms.

Let’s suppose we have different classes of varying shapes, such as squares, rectangles, and so on. They all will have the same method, calcArea(). But even if they have the same name, they will behave differently depending on the object type. This is called polymorphism. Polymorphism is considered one of the essential features of object-oriented programming. Let’s look at the different types.

Polymorphism can be classified in two ways, based on the time the procedure call is resolved:

  • Static Polymorphism
  • Dynamic Polymorphism

Get hands-on with 1200+ tech skills courses.