class Demo_Copy
{
int a,b;
public Demo_Copy(int x,int y)
{
a=x;
b=y;
}
public Demo_Copy(Demo_Copy obj)
{
a=obj.a;
b=obj.b;
}
void display()
{
System.out.println("a = "+a);
System.out.println("b = "+b);
}
}
class Copy_Constr
{
public static void main(String args[])
{
Demo_Copy obj1 = new Demo_Copy(10,20);
Demo_Copy obj2 = new Demo_Copy(obj1);
obj2.display();
}
}
{
int a,b;
public Demo_Copy(int x,int y)
{
a=x;
b=y;
}
public Demo_Copy(Demo_Copy obj)
{
a=obj.a;
b=obj.b;
}
void display()
{
System.out.println("a = "+a);
System.out.println("b = "+b);
}
}
class Copy_Constr
{
public static void main(String args[])
{
Demo_Copy obj1 = new Demo_Copy(10,20);
Demo_Copy obj2 = new Demo_Copy(obj1);
obj2.display();
}
}
No comments:
Post a Comment