Q24. What is polymorphism? Give an example illustrating polymorphism.

Ans. Polymorphism is the ability for a message or data to be processed in more than one form.

For example, if you give 5+7, it results into 12, the sum of 5 and 7. And if you give ‘A’+’BC’, it results into ‘ABC’, the concatenated strings. The same operation symbol ‘+’ is able to distinguish between the two operations (summation and concatenation) depending upon the data type it is working on. This is polymorphism.

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: