You are on page 1of 1

// Program to demonstrate class and objects

class Box
{
double l,w,h;
}

public class Boxdemo


{
public static void main(String[] args)
{
Box b1 = new Box();
Box b2 = new Box();
b1.l=30;
b1.h=20;
b1.w=10;
b2.l=50;
b2.h=30;
b2.w=40;

System.out.println("BOX b1 Details:");
System.out.println("Height" + b1.h);
System.out.println("Width" + b1.w);
System.out.println("Length" + b1.l);

System.out.println("BOX b2 Details");
System.out.println("Height" + b2.h);
System.out.println("Width" + b2.w);
System.out.println("Length" + b2.l);
}
}

Output:

BOX b1 Details:
Height 20.0
Width 10.0
Length 30.0
BOX b2 Details
Height 30.0
Width 40.0
Length 50.0

You might also like