Code:
Output:
class Overloading2
{
int x , y , z ;
Overloading2(int a )
{
x = a;
}
Overloading2(int a , int b)
{
x = a;
y = b;
}
Overloading2(int a , int b ,int c )
{
x = a;
y = b;
z = c;
}
void display()
{
System.out.println(" Object : X: "+x+" Y: "+y+" Z:"+z );
}
}
class Test2
{
public static void main( String args[] )
{
Overloading2 o1 = new Overloading2(10);
Overloading2 o2 = new Overloading2(20,30);
Overloading2 o3 = new Overloading2(40,50,60);
o1.display();
o2.display();
o3.display();
}
}
{
int x , y , z ;
Overloading2(int a )
{
x = a;
}
Overloading2(int a , int b)
{
x = a;
y = b;
}
Overloading2(int a , int b ,int c )
{
x = a;
y = b;
z = c;
}
void display()
{
System.out.println(" Object : X: "+x+" Y: "+y+" Z:"+z );
}
}
class Test2
{
public static void main( String args[] )
{
Overloading2 o1 = new Overloading2(10);
Overloading2 o2 = new Overloading2(20,30);
Overloading2 o3 = new Overloading2(40,50,60);
o1.display();
o2.display();
o3.display();
}
}
Output: