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);
}
}

Comments

Popular posts from this blog

Write a program to add two number using inline function in C++?

Traversing of elements program with algorithm and Flowchart