Answered step by step
Verified Expert Solution
Link Copied!

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.

image text in transcribedimage text in transcribed

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

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

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

Step: 3

blur-text-image

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

Relational Database And Transact SQL

Authors: Lucy Scott

1st Edition

1974679985, 978-1974679980

More Books

Students also viewed these Databases questions

Question

Explain the unearned revenue.

Answered: 1 week ago