Program:-
class Test
{
int x,y;
Test()
{
x=y=0;
}
Test(int m )
{
x=y=m;
}
Test(int x, int y)
{
this.x=x;
this.y=y;
}
void sum()
{
int c=x+y;
System.out.println("Sum of two numbers is"+" "+c);
}
}
class Test3
{
public static void main (String args [])
{
Test t1=new Test();
Test t2=new Test(40);
Test t3=new Test(30,30);
t1.sum();
t2.sum();
t3.sum();
}
}
Output:- Sum of two numbers is 0
Sum of two numbers is 80
Sum of two numbers is 60









