Wednesday, November 21, 2012

using interface area of circle


interface area
{
void carea();
}
interface pie
{
double pi=3.14;
}

class circle implements area,pie
{
int r;
public void carea()
{
System.out.println("Area of circle: "+pi*r*r);
}
circle(int r1)
{
r=r1;
}
}

class areac
{
public static void main(String args[])
{
circle c1=new circle(10);
c1.carea();
}
}


/*OUTPUT:

Area of circle: 314.0

*/

0 comments:

Post a Comment