1
Method Overloading Method Overriding 1. Happens in the same class Happens among two classes – a super class a subclass 2. No inheritance Happens in inheritance only 3. One method does not hide another Subclass method hides super class method 4. Should have different parameters Should have same parameters 5. Return type is not bothered Should have the same return type 6. Leads to static binding and static polymorphism Leads to dynamic binding , dynamic polymorphism and dynamic method dispatch

Method Overloading vs Method Overriding

Embed Size (px)

DESCRIPTION

Method overloading, Method Over-riding

Citation preview

Method OverloadingMethod Overriding

1. Happens in the same classHappens among two classes a super class and a subclass

2. No inheritanceHappens in inheritance only

3. One method does not hide anotherSubclass method hides super class method

4. Should have different parametersShould have same parameters

5. Return type is not botheredShould have the same return type

6. Leads tostatic binding and static polymorphismLeads todynamic binding,dynamic polymorphismanddynamic method dispatch