Inheritance
class Shape
{
int d1,d2,area;
Shape(int d1,int d2){
this.d1=d1;
this.d2=d2;
}
void disp(){
System.out.println("D1:"+d1);
System.out.println("D2:"+d2);
}
void findArea(){
area=d1*d2;
}
void dispArea(){
System.out.println("area is:"+area);
}
class Rectangle extends Shape
{
Rectangle(int d1,int d2){
super(d1,d2);
}
}
class Cuboid extends Shape
{
int d3,vol;
Cuboid(int d1,int d2,int d3)
{
super(d1,d2);
this.d3=d3;
}
void computeVolume(){
vol=d1d2d3;
}
void findArea(){
area=2*(d1d2+d2d3+d3*d1);
}
void disp()
{
System.out.println("D1:"+d1);
System.out.println("D2:"+d2);
System.out.println("heigth:"+d3);
}
void dispVolume(){
System.out.println("Volume:"+vol);
}
}
public static void main(String[] args){
Shape s1=new Shape(3,4);
s1.disp();
s1.findArea();
s1.dispArea();
}
}