click here

interface Area
{
	final static float pi = 3.14F;
	float calc (float m, float n);
}

class Square implements Area 
{
	public float calc (float m, float n)
	{
		return (m*n);
	}
}

class Circle implements Area
{
	public float calc (float m, float n)
	{
		return(pi*m*m);
	}
}

class TestInterface 
{
	public static void main (String args[])
	{
		Area ar;
		ar = new Square();
		System.out.println ("Area of square is "+ar.calc (15,15));
		ar = new Circle();
		System.out.println ("Area of circle is "+ar.calc(5,0));
	}
}

Click here to go back.

Our aim is to provide information to the knowledge seekers.


comments powered by Disqus




Natural Natural Natural Footer1