Pages

Saturday, 30 March 2019

Program to find area of rectangle using concept of Interface

interface Area
       {
   final static float pi = 3.14F;
   float compute (float x, float y);
       }
class Rectangle implements Area 
      {
        public float compute (float x, float y)
         {
            return (x*y);
         }}
class InterfaceTest
{
    public static void main (String args[])
  {
    Rectangle rect = new Rectangle();
   Area area;
  area = rect;
System.out.println ("Area of rectangle ="+area.compute(10,20));
}
}



OUTPUT:: 



No comments:

Post a Comment