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