//https://csprograms4u.blogspot.com/
//Chapter 3
//Program 2
//default constructor in Java
import
java.util.Scanner;
class
circle
{
private double r;
circle()
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter
Radius");
r=sc.nextDouble();
}
public double area()
{
return 3.14*r*r;
}
}
public
class Default_Constructor
{
public static void main(String args[])
{
circle c1=new circle();
System.out.println("Area of the
circle="+c1.area());
}
}
No comments:
Post a Comment
Note: only a member of this blog may post a comment.