Method overloading is a feature in Java that allows multiple methods within the same class to have the same name but different parameter lists. The methods must differ in the number of parameters, parameter types, or the order of parameters. It is a form of compile-time polymorphism because the method to execute is determined by the compiler.
A Calculator class may have multiple add() methods to handle different types and numbers of inputs.
class Calculator {
int add(int a, int b) {
return a + b;
}
int add(int a, int b, int c) {
return a + b + c;
}
double add(double a, double b) {
return a + b;
}
}
public class Demo {
public static void main(String[] args) {
Calculator calculator = new Calculator();
System.out.println(calculator.add(10, 20));
System.out.println(calculator.add(10, 20, 30));
System.out.println(calculator.add(10.5, 20.5));
}
}30
60
31.0calculate(int a)
calculate(int a, int b)calculate(int a)
calculate(double a)calculate(int a, String b)
calculate(String b, int a)int calculate(int a)
double calculate(int a)
The above is invalid because only the return type differs.
A concise interview answer is
Method overloading is the ability to define multiple methods with the same name in the same class but with different parameter lists. It is a form of compile-time polymorphism and helps improve code readability and flexibility.
Last updated: 16 July 2026
Previous question: How do you serialize an object with circular references in Java?
Next question: How does the Java compiler determine which overloaded method to call?