Saturday, 15 June 2013

Write a program to calculate the sum of two numbers of different type using the concept of Method Overloading?



class a
{
public void sum(int x,int y)
{
System.out.println(x+y);
}
public void sum(int x,int y,int z)
{
System.out.println(x+y);
}
}
class m
{
public static void main(String args[])
{
a obj=new a();
obj.sum(6,5,2);
obj.sum(10,20);
}
}

No comments:

Post a Comment