Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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.
**********************************************************
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. bStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started