Java Program to find area of circle using Final Class, Write a java program to find area of circle using final keyword
Program
final class Fincircle
{
double area;
double radius;
final double PHI=22.0/7.0;
Fincircle(double r)
{
radius =r;
}
double Area()
{
area=PHI*radius*radius;
return area;
}
}
class finalcls
{
public static void main(String args[])
{
double ar;
Fincircle F=new Fincircle(3.5);
ar=F.Area();
System.out.println("Area of Circle is:"+ar);
}
}
No comments:
Post a Comment