Difference between overloading and overriding in java

S.NO

Method Overloading

Method 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 cannot be be same, but we must have to change the parameter.

While in this, return type must be same or co-variant.

 


Comments

Popular posts from this blog

Inheritance in Java

Type Conversions

Life cycle of a Thread and creating thread class