Thursday 29 March 2012

Polymorphism

Polymorphism :

Polymorphism is another important OOP concept. Polymorphism means the ability to take more than one form. For example, an operation may exhibit different behavior in different instances. The behavior depends upon the types of data used in the operation. For example consider the operation of addition. For two numbers, the operation will generate a sum. If the operands are strings, then the operation would produce a third string by Concatenation. Figure illustrates that a single function name can be used to handle different number and different types of arguments. This is something similar to a particular word having several different meanings depending on the context.


Polymorphism plays an important role in allowing objects having different internal structures to share the same external interface. This means that a general class of operation may be accessed in the same manner even though specific actions associated with each operation may differ. Polymorphism is extensively used in implementing inheritance.

No comments:

Post a Comment