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

Featured post

Kalgudi Interview Round!!

Those who cleared the second round of kalgudi got an email from exceller to complete their Kalgudi Interview Round. So here we will discuss ...