class rectangle
{
int l,b;
rectangle()
{
System.out.println("\nrectangle()");
l=10;
b=20;
}
rectangle(int x)
{
System.out.println("\nrectangle(int x)");
l=x;
b=x;
}
rectangle(int x, int y)
{
System.out.println("\nrectangle(int x , int y)");
l=x;
b=y;
}
void area()
{
System.out.println("area :"+(l*b));
}
}
class constuctordemo3
{
public static void main(String args[])
{
rectangle r1= new rectangle(5,15);
rectangle r2= new rectangle();
rectangle r3= new rectangle(100);
System.out.println("\n\narea() with r1");
r1.area();
System.out.println("\n\narea() with r2");
r2.area();
System.out.println("\n\narea() with r3");
r3.area();
rectangle r4=r1; //here address of r1 copied to address r4
System.out.println("\n\narea() with r4");
r4.area();
rectangle r5=r3; //here address of r3 copied to address r5
System.out.println("\n\narea() with r5");
r5.area();
}
}
{
int l,b;
rectangle()
{
System.out.println("\nrectangle()");
l=10;
b=20;
}
rectangle(int x)
{
System.out.println("\nrectangle(int x)");
l=x;
b=x;
}
rectangle(int x, int y)
{
System.out.println("\nrectangle(int x , int y)");
l=x;
b=y;
}
void area()
{
System.out.println("area :"+(l*b));
}
}
class constuctordemo3
{
public static void main(String args[])
{
rectangle r1= new rectangle(5,15);
rectangle r2= new rectangle();
rectangle r3= new rectangle(100);
System.out.println("\n\narea() with r1");
r1.area();
System.out.println("\n\narea() with r2");
r2.area();
System.out.println("\n\narea() with r3");
r3.area();
rectangle r4=r1; //here address of r1 copied to address r4
System.out.println("\n\narea() with r4");
r4.area();
rectangle r5=r3; //here address of r3 copied to address r5
System.out.println("\n\narea() with r5");
r5.area();
}
}