What is Polymorphism?

What is Polymorphism?

1 Like

In simple words, polymorphism means that some code or operations or objects behave differently in different contexts. It is also called overloading.

Polymorphism can be static or dynamic. In static polymorphism, the memory will be allocated at compile-time. In dynamic polymorphism, the memory will be allocated at run-time.

As an example, you can assume we have two functions with same name but different number of arguments. So, based on how many and what parameters we pass during function call determines which function is to be called, this is why it is considered as an example of polymorphism because in different conditions the output will be different.