Create a custom class
Due Date: Thursday of Week 4
10 points
In this lab, you'll experiment with custom classes and chained exceptions.
- Create a custom checked exception class named TestException that contains two constructors: one that accepts no parameters and one that accepts a String message.
- Open the CustomTesterApp class.
Add a statement to Method3 that throws a TestException without a message. (You'll also need to delete or comment out the last statement in Method3 or the compiler will flag it as unreachable.) Add the code necessary to catch this exception in Method2. The catch block should simply display a message at the console. Compile and run the program and observe its operation.
Modify your solution so that a custom message is passed to the TestException and is then displayed in the catch block. Compile and run the program to be sure that the custom message is displayed.
Add another constructor to the TestException class that accepts a Throwable object as a parameter.
Add a try statement to Method3 of the CustomTesterApp class. The try clause should throw an IOException, and the catch clause should throw a TestException, passing the IOException to its constructor.
Modify the catch block in Method2 that catches the TestException so that it displays the original cause of the exception. Compile and run the application to make sure it works.
Include in your program the following comments:
- Name of program
- Team's name with all the names of the members (e.g. Team A: John Doe, Jane Smith, etc.)
- Current Date
- Computer system and compiler you are using
- Brief description of the program
Compile and run the Java program.
Take a screen capture by hitting simultaneously the keys Alt and Print Screen (Prt Sc) of the output results (console) and paste it in MS Paint. Save it as a gif file.
When you are ready, upload the java program and the gif file by clicking the link below:
Upload Lab
I cannot grade if I don't get the files and receive your email.