JAVA PROGRAMS-Java Program using Super key
Java Program using Super key
Program Name:- superkey.java
class rectangle
{
int length,breadth;
rectangle(int l,int m)
{
length=l;
breadth=m;
}
int area()
{
int a;
a=length*breadth;
return(a);
}
}
class box extends rectangle
{
int height;
box(int l,int b,int h)
{
super(l,b);
height=h;
}
int volume()
{
int v;
v=length*breadth*height;
return(v);
}
}
class superkey
{
public static void main(String args[])
{
box in=new box(10,10,10);
int a,v;
a=in.area();
v=in.volume();
System.out.print("\nArea\t:"+a);
System.out.print(" \nVolume\t:"+v);
}
}
No comments:
Post a Comment