Function overloading and overriding has been already introduced in C++ . Java is a pure object oriented programming language and functions are considered methods. Method overloading is similar to function overloading of c++. Only same class's methods can be overloaded by using different number and types of parameters but with same function name and return type. Now comes to method overriding, method overriding is applicable in the case of base and child class. For the method overriding, the method signature should be same but return type may be different.
Example of method overloading:
class sum
{
int add (int i, int j)
{
return i+j;
}
int add (int i, int j, int k)
{
return i+j+k;
}
public static void main(String args[])
{
}
}
Example of method overriding:
class base
{
public int speedLimit()
{
return 100;
}
}
class child extends base
{
public int speedLimit()
{
return 150;
}
public static void main(String args[])
{
}
}