Question: Write a program to create a class CirclesWithException with the following information: radius in double with private access specifier. Use public methods setRadius() and getRadius()
Write a program to create a class CirclesWithException with the following information:
radius in double with private access specifier.
Use public methods setRadius() and getRadius() to access radius of the circle. setRadius() method throws an IllegalArgumentException if the argument radius is negative.
Add a constructor to pass on radius of a Circle. Call setRadius() method to set the radius of circle inside the constructor.
Use printRadius( ) to display the radius if object is created.
Use printStackTrace() and getMessage() methods to obtain information from exception objects in corresponding catch block.
Create three objects of class CirclesWithException with positive, negative and zero radius.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
