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