class Box {
double width;
double height; //instance variable
double depth;
double volume() {
return width*height*depth;
}
void setDim(double w, double h, double d) {
width =w;
height =h;
depth=d;
}
}
class BoxDemo {
public static void main(String[] args) {
Box mybox1 = new Box(); //here created two box object.
Box mybox2 = new Box();
double vol;
// assign value to instance
mybox1.setDim(10,20,15);
mybox2.setDim(3, 6, 9);
vol = mybox1.volume();
System.out.println(vol);
vol= mybox2.volume();
System.out.println(vol);
}
}