Question: with java language Summary Practice exception handling and develop your own class of exception derived from the Java API's Exception class. Problem (2 points) 1.
Summary Practice exception handling and develop your own class of exception derived from the Java API's Exception class. Problem (2 points) 1. Write code for the following class called RectanglewithExceptions. RectangleWithExceptions le) height: double width: double RectangleWithExceptions() RectangleWithExceptions(double, + setHeight(double height) : void + setWidth(double width): void + getHeight(): double + getWidth(): double + getAreal): double 2. Now add two custom exception classes to your project called a. InvalidHeightException Thrown whenever a negative value is attempted to be assigned to height b. InvalidwidthException Thrown whenever a negative value is attempted to be assigned to width 3. Use both these exceptions in appropriate places in your RectangleWithException class 4. Write a test program in which you demonstrate these exceptions by writing separate catch blocks for the following exception classes: a. InvalidHeightException b. InvalidWidthException C. Exception 5. Also add a finally block
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
