Method Overloading
Method overloading is a feature of java in which one class can have more than one method with the same name but different parameter list(either data type or the number of arguments should be different). * If only return type is different then it can't be considered as function overloading. It can be
Method overloading is a feature of java in which one class can have more than one method with the same name but different parameter list(either data type or the number of arguments should be different). * If only return type is different then it can't be considered as function overloading. It can be called function overloading also. Function overloading is very useful in a class where one operation(task) can be performed with different types of arguments with the same name. Here is an example of function overloading.
Develop a Program that illustrate method overloading concept. Read about the concept here
class Object
{
public int Add(int a, int b)
{
return (a + b);
}
public int Add(int a, int b, int c)
{
return (a + b + c);
}
public int Add(int a, int b, int c, int d)
{
return (a + b + c + d);
}
}
public class Practical15
{
public static void main(String[] args)
{
Object o = new Object();
System.out.println("Add 1 => " + o.Add(4, 5));
System.out.println("Add 1 => " + o.Add(4, 5, 6));
System.out.println("Add 1 => " + o.Add(4, 5, 6, 7));
}
}
Related Posts
Continue learning with these related articles

Logic Gates for ISC Class 11: Truth Tables, Universal Gates, Half and Full Adder
ISC Class 11 Computer Science notes on logic gates: AND, OR, NOT, NAND, NOR, XOR and XNOR with truth tables, why NAND and NOR are universal gates, and half adder and full adder circuits with their Boolean expressions.
Decimal to Binary Conversion in Java: 3 Programs with Examples
How to convert a decimal number to binary on paper and in Java: three programs (String, place value and Integer.toBinaryString), binary to decimal, a dry run and common mistakes.
Sum of First n Natural Numbers in Java (Loop and Formula)
Find the sum of the first n natural numbers in Java with a for loop, a while loop and the formula n(n + 1)/2, with a dry run and the sums of even numbers, odd numbers, squares and cubes.