Box_object
class box{
public int len;
private int bred;
private int height;
public box(){
len =1;
bred = 2;
height = 4;
}
public box(int e){
len = bred = height = e;
}
public box(int l,int b, int h){
len = l;
bred = b;
height = h;
}
public int getArea(){
return len * bred;
}
public int getVolume(){
return len * bred * height;
}
}
class box_demo{
public static void main(String[] owl){
box[] b1 = new box[5];// create object
b1[0] = new box(2,9,5);
b1[1] = new box(8,9,1);
b1[2] = new box(7);
b1[3] = new box();
b1[4] = new box(8);
if(b1[0].getArea() > b1[1].getArea()){
System.out.print("b1 is greater in area");
}
if(b1[0].getVolume() > b1[1].getVolume()){
System.out.print("b1 is greater in volume");
}
int i=0;
do{
System.out.println("Area: "+b1[i].getArea());
i = i + 1;
}while(i