class Cube
{
int length;
public Cube(int len)
{
length=len;
}
void display()
{
System.out.println("length="+length);
}
public void surface()
{
int s=length*length*length;
System.out.println("surface="+s);
}
}
class Cuboid extends Cube
{
int height,width;
Cuboid(int ht,int wd,int l)
{
super(l);
height=ht;
width=wd;
}
public void volume()
{
int vol;
vol=height*width*length;
System.out.println("volume="+vol);
}
}
class Cube_Cuboid
{
public static void main(String ad[])
{
Cuboid cb=new Cuboid(10,2,5);
cb.display();
cb.surface();
cb.volume();
}
}
Output:
length=5
surface=125
volume=100
0 Comments
Post a Comment