interface area
{
final static float pi=3.14F;
float compute(float x,float y);
}
class rect implements area
{
public float compute(float x,float y)
{return (x*y);
}
}
class circle implements area
{
public float compute(float x,float y)
{
return (pi*x*x);
}
}
class intrface
{public static void main(String args[])
{
rect re=new rect();
circle ci=new circle();
area ar;
ar=re;
System.out.println("Area of rectangle"+ar.compute(10,20));
ar=ci;
System.out.println("Area of circle="+ar.compute(10,0));
}
}
OUTPUT:
0 comments:
Post a Comment