Question: Q2) THE CIRCLE CLASS Write a utility class Circle and a driver class CircleTest test each constructor and method in the class. Recall that the

Q2) THE CIRCLE CLASS Write a utility class Circle and a driver class CircleTest test each constructor and method in the class. Recall that the Math class defines the constant public static final double PI. A Circle object should have one instance variable: double radius and one class constant that defines the default radius of 1. Include two constructors: o public Circle(double r) initializes the radius to r o public Circle() initializes the radius to the default radius Include the following methods: o public double area() returns the area (r2 )of this Circle o public double circumference() returns the circumference (2r) of this Circle public double diameter() public String toString() returns a String representation of this Circle such as o "Circle with radius 2.5" public void setRadius(double r) sets the radius tor public double getRadius() returns the radius of this Circle o o
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
