Method Overloading in Java

If a class has multiple methods having the same name but different in parameters, it is known as Method Overloading.

If we have to perform only one operation, having the same name as the methods increase the readability of the program.

Suppose you have to perform addition of the given numbers but there can be any number of arguments, if you write the method such as an (int, int) for two parameters, and b(int, int, int) for three parameters then it may be difficult for you as well as other programmers to understand the behavior of the method because its name differs.
By changing the no. of arguments
By changing the datatype
Why method overloading is not possible by changing the return type
Can we overload the main method
method overloading with Type Promotion.

 
avatar

Thank you for all your help and assistance over the years with our products.

avatar

"My experience at Java E Training is valued and I loved every leaning moment here."

Sai
Phone: +91-9640400300
Email: mahesh@javaetraining.com,
Email: javaetraining@gmail.com
Gachibowli,
Hyderabad, IN 500032