//Create the referance of the Operation class in Circle
class Operation
{
int square(int n)
{
return n*n;
}
}
class Circle{
Operation op;
double pi=3.14;
double area(int radius)
{
op=new Operation();
int rsquare=op.square(radius);
return pi*rsquare;}
public static void main(String[]args)
{
Circle c=new Circle();double result=c.area(5);
System.out.println(result);
}
} That is Output
- c:/shashi/javac Operation.java
- c:/shashi/java Circle
- 78.
0 comments:
Post a Comment