Interview Question

What is method overloading?

Overloading uses one method name with different parameter lists.

💡 Concept ✅ Quick Revision ☕ Java

Answer

Method overloading declares methods with the same name but different parameter signatures. • Overload selection happens at compile time. • Return type alone cannot distinguish overloads. • Varargs, boxing, and conversions can make overload resolution surprising.

Example

Code
static int add(int a, int b) { return a + b; }
static double add(double a, double b) { return a + b; }
System.out.println(add(2, 3));
Output
5

Quick Revision

Overloading uses one method name with different parameter lists.