Question: JAVA only please Write a program that illustrates rethrowing an exception. Define methods someMethod and someMethod2. MethodsomeMethod2 should initially throw an exception. Method someMethod should

JAVA only please

Write a program that illustrates rethrowing an exception. Define methods someMethod and someMethod2. MethodsomeMethod2 should initially throw an exception. Method someMethod should call someMethod2, catch the exception and rethrow it. Call someMethod from methodmain, and catch the rethrown exception. Print the stack trace of this exception.

JAVA only please Write a program that illustrates rethrowing an exception. Definemethods someMethod and someMethod2. MethodsomeMethod2 should initially throw an exception. Method someMethod

**********************************************************

Thanks!

Purpose: Understanding Exception chaining General Information Referring to Exercise 11.20 (page 439 of the text), you will write code to demonstrating chaining an Exception, instead of demonstrating a rethrow of an Exception Requirements You will write a Java process module that meets the following requirements: The module will contain two methods (outside of the main method): firstMethod and secondMethod. The main method will call firstMethod. Method firstMethod will call method secondMethod. Method secondMethod will throw an Exception passing the String "This Exception thrown in secondMethod." 1. 2. 3. 4. 5. Method firstMethod will catch the Exception thrown in secondMethod, and will chain the Exception, adding the String message "This Exception caught in secondMethod, chained, and thrown as a new Exception.". 6. The main method will catcth the Exception and perform the following tasks Output the entire message text to the System.err stream Output the stack trace to the System.err stream a. b

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!