Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

package murach.test; import java.io.*; public class CustomTesterApp { public static void main(String[] args) { Method1(); } public static void Method1() { Method2(); } public static

image text in transcribed package murach.test; 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. } }
3 More essential skills tion to make sure the finally clause works as expec if the file is never opened, you can change the na 528 Section s To test 4. Run the application t hap Eile NotFoundException. To test what happens if e closeO ou can throw an IOException just before the statement method use to cau that closes the resource. Create riment with custom classes and chained exce a custom class Exercise 16-3 In this 1. Open the project exercise, you 'll expe you fl experiment with custom classes and chained amed ch16 ex3 Custom Tester in the ex starts folde Cust 1. Open e a custom checked exception class named TestException ss named TestException that contains two constructors: one that accepts no parameters and one that accepts a message the Custom TesterApp class. Then, add a statement to method30 2 Open throws a TestException without a message. Add the code neces this exception in method20. The catch block should print a messao choice at the console. Run the application to make sure it works co y. Modify your solution so a custom message of your choice is passed to 3. TestException and is then displayed in the catch block. Run the application make sure the custom message is displayed correctly. 4. Add another constructor to the TestException class that accepts a Throwab object as a parameter. Add a try statement to method30 of the Main class. throw an IOException, and the catch block should throw a TestExce passing the IOException to its constructor. 5. The try block should ption, 6. Modify the catch block in method20 that catches the TestException so it prints a message that gives information about the exception and its underlying cause. Run the application to make sure it works correctly

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advanced Database Systems

Authors: Carlo Zaniolo, Stefano Ceri, Christos Faloutsos, Richard T. Snodgrass, V.S. Subrahmanian, Roberto Zicari

1st Edition

155860443X, 978-1558604438

More Books

Students also viewed these Databases questions

Question

find all matrices A (a) A = 13 (b) A + A = 213

Answered: 1 week ago

Question

Connect with your audience

Answered: 1 week ago