source file name:  rectdemo.java

import java.io.*;

class rectangle

{

int x,y,len,bd;

public rectangle()

{

x=y=0;

len=bd=0;

}

public rectangle(int lenbd)

{

x=y=10;

len=bd=lenbd;

}

public rectangle(int xc, int yc, int leng, int bdt)

{

x=xc;

y=yc;

len=x+10;

bd=y+10;

}

void display()

{

System.out.println("x="+x+" y="+y+" length="+len+" breadth="+bd);

}


public void findpoint(rectangle r, int xc, int yc)

{

if((xc>r.x || yc>r.y)&&(xc<r.len || yc<r.bd))

System.out.println("Current point lies in this rectangle");

else

System.out.println("Current point out of this rectangle");

}

public rectangle largerect(rectangle r1,rectangle r2)

{

rectangle r=new rectangle();

if((r1.x>r2.x||r1.y>r2.y)&&(r1.len>r2.len||r1.bd>r2.bd))

r=r1;

else

r=r2;

return r;

}

}

class rectdemo

{

public static void main(String as[])

rectangle r1=new rectangle(25);

r1.display();

rectangle r2=new rectangle(2,6,15,25);

r2.display();

rectangle r3=new rectangle(10,10,15,25);

r3.findpoint(r3,15,20);

r3.findpoint(r3,15,5);

rectangle r4=new rectangle(100,10,15,25);

rectangle r=new rectangle();

r=r.largerect(r3,r4);

System.out.println("Largest rectangle is: ");

r.display();

}

}

output:

D:\JavaPrograms\Constructors>javac rectdemo.java

D:\JavaPrograms\Constructors>java rectdemo
x=10 y=10 length=25 breadth=25
x=2 y=6 length=12 breadth=16
Current point lies in this rectangle
Current point lies in this rectangle
Largest rectangle is:
x=100 y=10 length=110 breadth=20