What is the use of interface if it should be defined in the subclass implementing it? Also, to access an interface we need to create an object of that class.
import java.io.*;
Interface area
{
compute();
}
Class rectangle implements area
{
compute()
{
x*y;
}
}
Class circle implements area
{
compute()
{
x*y;
}
}
Class test
{
public static void main(String args[])
{
rectangle r=new rectangle();
area ar;
ar=r;
ar.compute();
}
}