Microsoft Store
 

Polymorphism in object-oriented programming


 

In object-oriented programming theory, polymorphism is the ability of objects belonging to different types to respond to methods of the same name, each one according to the right type-specific behavior. The programmer (and the program) does not have to know the exact type of the object in advance, so this behavior can be implemented at run time (this is called late binding or dynamic binding).

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

The different objects involved only need to present a compatible interface to the clients (the calling routines). That is, there must be public methods with the same name and the same parameter sets in all the objects. In principle, the object types may be unrelated, but since they share a common interface, they are often implemented as subclasses of the same parent. Though it is not required, it is understood that the different methods will also produce similar results (for example, returning values of the same type).

~ ~ ~ ~ ~ ~ ~ ~ ~ ~