It is the third essential feature of OOPs after data abtraction and inheritence we can define polymorphysm in one sentence - one interface many formn.
Polymorphysm is the ability to define many different operation using the same name . Literally it means many forms and is taken from the greek polos (many) and morpye (form) meaans that ability to take more than one form.
An operation may exhibit different behaviours in different instancess (part). The behaviour depend upon the type of data used in the operation.
We can explain polymorphysm by the phrase :-
"One interface multiuple methods"
It helps to reduce complexity by ballowing the same interface for different clas of action.
It is compilers job to select the specific action (method) as it applies to each situation .
It also improves code readability as well as the creation of extensible programs. In general way a single function name can be used to handle diffderernt no. and different types of arguments.
We can also use (area) when we are going to calculate area of different shapes.
No comments:
Post a Comment