Polymorphism

By: aathishankaran Printer Friendly Format    

Polymorphism

 

Polymorphism is a feature that allows one interface to be used for a general class of action. The specific action is determined by the exact nature of the situation. Consider a stack. You might have a program that requires three type of stack.

 

One stack is used for integer values, one for floating-point values and another for characters. However, because of polymorphism, in Java you can specify a general set of stack routines that all share the same names.

 

More generally, the concept of polymorphism is often expressed by the phrase "one interface, multiple methods." This means that it is possible to design a generic interface to a group of related activities. This helps reducing complexity allowing the same interface to be used to specify a general class of action.

 

It is compiler's job to select the specific action as it applies to each situation. You, the programmer, do not need to make this selection manually.

 

 





Most Viewed Articles (in Java )

Latest Articles (in Java)

Comment on this tutorial