Definition

It means having methods of the same class under the same name, but each method has different parameters or has same parameters with different types and order.

It means having a sub class with same methods under same name and exactly the same type of parameters and the same return type as a super class.

Polymorphism

Overloading is a compile time polymorphism.

Overriding is a run time polymorphism.

Static method

The static method can be overloaded.

The static method cannot be overridden.

Inheritance

Overloading may or may not require inheritance.

Overriding always requires inheritance.

Speed

Overloading is faster than overriding.

Overriding is slow as compared to overloading.

Signature

In Overloading methods have different signature.

In Overriding methods must have same signature.

Classes

Overloading does not require more than one class for overloading.

Overriding requires at-least two classes for overriding.

Example

Java Method Overloading example

Java Method Overriding example

It's good to share...Share on FacebookTweet about this on TwitterShare on LinkedInPin on PinterestShare on Google+Email this to someone

Leave a Reply

Your email address will not be published. Required fields are marked *