Method overloading using changing no of argument

Method overloading using changing no of argument
class test
{
void sum(int a,int b)
{
System.out.println(a+b);
}
void sum(int a,int b,int c)
{
System.out.println(a+b+c);
}
public static void main(String args[])
{
test obj=new test();
obj.sum(10,20,30);
obj.sum(10,20);
}
}

Output:
60
30

Leave a Reply

Your email address will not be published. Required fields are marked *