// Here,Box allows one object to initialize another.
class Box { double width; double height; double depth;
// construct clone of an object
Box(Box ob) { // pass object to constructor
width = ob.width;
height = ob.height;
depth = ob.depth;
}
// constructor used when all dimensions specified
Box(double w,double h,double d) {width = w; height = h;depth = d;
}
// constructor used when no dimensions specified
Box() { width = -1; // use -1 to indicate height = -1; // an uninitializeddepth = -1; // box
}
// constructor used when cube is created Box(double len) { width = height = depth = len;}
// compute and return volume double volume() { return width * height * depth;}}
class OverloadCons2 {
public static void main(String args[]) { // create boxes using the various constructorsBox mybox1 = new Box(10,20,15);Box mybox2 = new Box();Box mycube = new Box(7);
Box myclone = new Box(mybox1);
double vol;
// get volume of first box