1. What is Polymorphism:
=> Poly Means More then One Form
Real Life Example of Polymorphism.
A person at a same time can have different characteristic.
Like a man at a same time is a father, a husband, a employee.
So a same person posses have different behaviour in different situations.
Two Types of Polymorphism:
1.Compile time polymorphism. ie early binding,or static binding:
Method Overloading:
advantage of CTP is execution will be fast.
example:= Overloaded method, overloaded orator.
2. Dynamic Polymorphism: late binding or Run Time Polymorphism
Example of Method overriding
Method Overloading:
Same method Name with different type of parameter or different set of parameter in a same class is called method overloading.
Method overloading provides more than one form for a method. Hence it is an example for Polymorphism.
Method overriding:
Creating a method in a derived class of same signature as method in a base class is called method overriding.
same signature means method must have same name,same argument, and same type of argument.
method overriding is possible in only derived class not within same class.
=> Poly Means More then One Form
Real Life Example of Polymorphism.
A person at a same time can have different characteristic.
Like a man at a same time is a father, a husband, a employee.
So a same person posses have different behaviour in different situations.
Two Types of Polymorphism:
1.Compile time polymorphism. ie early binding,or static binding:
Method Overloading:
advantage of CTP is execution will be fast.
example:= Overloaded method, overloaded orator.
2. Dynamic Polymorphism: late binding or Run Time Polymorphism
Example of Method overriding
Method Overloading:
Same method Name with different type of parameter or different set of parameter in a same class is called method overloading.
Method overloading provides more than one form for a method. Hence it is an example for Polymorphism.
Method overriding:
Creating a method in a derived class of same signature as method in a base class is called method overriding.
same signature means method must have same name,same argument, and same type of argument.
method overriding is possible in only derived class not within same class.
No comments:
Post a Comment