Method overloading is when multiple Methods of the same name can be defined, and the compilerdecides which method to invoke based on a method signature. Method overloading promotes Polymorphism in a program
Constructors can also be (and often are) overloaded
Examples
Method overloading is exclusive to Object Oriented Programming Languagess:
Java
public class Car
{
int speed;
int defaultAccelerationValue = 10;
void Accelerate()
{
speed += defaultAccelerationValue;
}
//Overloaded version of Accelerate, with custom acc
void Accelerate(int customAcc)
{
speed += customAcc;
}
}
Constructor methods can also be (and often are) overloaded:
public Circle() {
public double radius;
public Circle() {
radius = 5.0;
}
//Overloaded methods that specify custom radius
public Circle(double radius) {
this.radius = radius
}