Method Overloading In Java

A class having multiple methods with same name but different parameters is called Method Overloading

There are three ways to overload a method.

1. Parameters with different data types

2. Parameters with different sequence of a data types

3. Different number of parameters

Earlier we have seen method signature. At compile time, Java knows which method to invoke by checking the method signatures. So this is called compile time polymorphism or static binding.

Let’s see some practical example for better understanding.

1. Parameters with different data types

Output:

2. Parameters with different sequence of a data types

Output:

3. Different number of parameters

Output:

Must Read: Java Tutorial

Rajkumar SM is a founder of SoftwareTestingMaterial. He is a certified Software Test Engineer by profession and blogger & youtuber by choice. He has an extensive experience in the field of Software Testing. He writes here about Software Testing which includes both Manual and Automation Testing. He loves to be with his wife and cute little kid 'Freedom'.

Leave a Comment

Share via
Copy link
Powered by Social Snap