import java.io.*;
class Box
{
int width;
int height;
int depth;
Box(int w, int h, int d)
{
width = w;
height =h;
depth = d;
}
void getVolume()
{
System.out.println("Volume is : " + width * height * depth);
}
}
class MatchBox extends Box
{
int weight;
MatchBox(int w, int h, int d, int m) {
super(w, h, d);
weight = m;
}
}
class inheritanceDemo
{
public static void main(String args[]) throws IOException
{
int width ,w;
int height ,h;
int depth,d ;
int weight,m;
BufferedReader in=new BufferedReader
(new InputStreamReader(System.in));
System.out.print("enter the value of width = ");
w= Integer.parseInt(in.readLine());
System.out.print("enter the value of height = ");
h= Integer.parseInt(in.readLine());
System.out.print("enter the value of depth = ");
d= Integer.parseInt(in.readLine());
System.out.print("enter the value of weight = ");
m= Integer.parseInt(in.readLine());
MatchBox mb1 = new MatchBox(w,h,d,m);
mb1.getVolume();
System.out.println("width of MatchBox one is = " + mb1.width);
System.out.println("height of MatchBox one is= " + mb1.height);
System.out.println("depth of MatchBox one is = "+ mb1.depth);
System.out.println("weight of MatchBox one is= " + mb1.weight);
}
}
|