Thursday, November 19, 2015

Program to demostrate the use of super keyword.

class Reclangle
{
double length, width,area;
Reclangle(double l, double w)
{
length=l;
width=w;
area=length*width;
System.out.println("Area of Rectangle is : "+area);
}
}
class Cuboid extends Reclangle
{
double height, volume;
Cuboid(double l,double w,double h)
{
super(l,w);
height=h;
volume=length*width*height;
System.out.println("VoIume of cuboid is : "+volume);
}
}
class Demosuper
{
public static void main(String args[])
{
Cuboid obj=new Cuboid(10,15,20);
}
}
Output:


No comments:

Post a Comment