Question: This is from Murach Java exercise 14-3. It has a few tasks to be added to the code listed below: Contains custom checked exception class

This is from Murach Java exercise 14-3. It has a few tasks to be added to the code listed below:

Contains custom checked exception class TestException that compiles correctly

method3 throws TestException with a custom message

method2 catches TestException and displays the message on the console

TestException has a constructor that takes a Throwable parameter and a String parameter

try statement in method3 throws IOException

catch block in method3 throws TestException, passing IOException and a message to its constructor

catch block in method2 displays original cause of exception

___________________________________________________

import java.io.*;

public class CustomTesterApp

{

public static void main(String[] args)

{

Method1();

}

public static void Method1()

{

Method2();

}

public static void Method2()

{

Method3();

}

public static void Method3()

{

//Add code to throw an exception here.

}

}

Thanks for the Help!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!