I tried running this code in Java Netbeans.I have a doubt as to why its volume of mybox1 and mybox2 is same??
class box { double width,height,depth; box(double w,double h,double d){ width=w; height=h; depth=d; } box(box b){ width = b.width; height = b.height; depth = b.depth; } /* box(double len){ width= height= depth=len; }*/ double volume(){ return width*height*depth; } } class BoxWeight extends box{ double weight; BoxWeight(double w,double h,double d,double m){ super(w,h,d); weight = m; } BoxWeight(box b,double w){ super(b); weight = w; } } public class super_class { public static void main(String args[]){ BoxWeight mybox1 = new BoxWeight(10.5 , 20.5 , 30.5 , 40.5); BoxWeight mybox2 = new BoxWeight(mybox1, 5.5); double vol; vol = mybox1.volume(); System.out.println("Volume of mybox1 is "+ vol); System.out.println("Weight of mybox1 is "); System.out.println(mybox1.weight); System.out.println("Volum