Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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: 1. The module will contain two methods (outside of the main method): firstMethod and secondMethod. 2. The main method will call firstMethod. 3. Method firstMethod will call method secondMethod. 4. Method secondMethod will throw an Exception passing the String This Exception thrown in secondMethod.. 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 catch the Exception and perform the following tasks: a. Output the entire message text to the System.err stream. b. Output the stack trace to the System.err stream.

Expected Output The ellipses at the end indicate that the stack trace continues for some lines after the portion shown (Line numbers and program name for your output will likely be different from these).

This Exception caught in secondMethod, chained, and thrown as a new Exception.

java.lang.Exception: This Exception caught in secondMethod, chained, and thrown as a new Exception. at Lab07.firstMethod(Lab07.java:34) at Lab07.main(Lab07.java:14) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) Grading If your program compiles clearly and functions exactly as required, your grade will be 100%. Otherwise, it will be 0%.

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

Beginning C# 2005 Databases

Authors: Karli Watson

1st Edition

0470044063, 978-0470044063

More Books

Students also viewed these Databases questions