class WhatIsInheritance{
public static void main(String []args){
Box box1 = new Box();
Box box2 = new Box(1,2,3);
int vol=box2.volume();
System.out.println("volume= "+vol);
ColorBox box3 = new Colorbox(3,4,5,6);
int voltwo=box3.volume();
System.out.println("Super Volume= "+voltwo);
System.out.println("Color= "+box3.color);
}
}
class Box{
int width;
int height, depth;
int volume(){
return width * height * depth;
}
Box(){
width=-1;
height=-1;
depth=-1;
}
Box(int comm){
comm= width= height= depth;
}
Box(int a, int b, int c){
width=a;
height=b;
depth=c;
}
}
class ColorBox extends Box{
int color;
ColorBox(int a, int b, int c, int d){
color=a;
width= b;
height=c;
depth= d;
}
}