METHOD OVERLOADING vs OVERRIDING

Difference between Method Overloading and Method Overriding in Java:

S.NOMETHOD OVERLOADINGMETHOD OVERRIDING
1.Method overloading is a compile time polymorphism.Method overriding is a run time polymorphism.
2.It help to rise the readability of the program.While it is used to grant the specific implementation of the method which is already provided by its parent class or super class.
3.It is occur within the class.While it is performed in two classes with inheritance relationship.
4.Method overloading may or may not require inheritance.While method overriding always needs inheritance.
5.In this, methods must have same name and different signature.While in this, methods must have same name and same signature.
6.In method overloading, return type can or can not be be same, but we must have to change the parameter.While in this, return type must be same or co-variant.

Popular posts from this blog

36 LOGICAL "OR" OPERATOR

Arrays

ENCAPSULATION