Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In the first part of this challenge, you will write a program that demonstrates that an exception superclass will catch exceptions of exceptions thrown by

In the first part of this challenge, you will write a program that demonstrates that an exception superclass will catch exceptions of exceptions thrown by its exception subclasses. In the second part of this challenge, you will write another program that demonstrates how exceptions are caught with catch (Exception exception). Each of these skeleton application programs run independently of each other. Specifications Part A Use inheritance to create an exception superclass (called ExceptionA) and exception subclasses ExceptionB and ExceptionC. Refer to the diagram (right). Each of these classes may be written with an empty class body. Write an application named Test1 with these classes included. Demonstrate that the catch block for type ExceptionA catches exceptions of ExceptionB and ExceptionC. Sample output is shown below. Part B Reuse your code from Part A for these classes: o ExceptionA (which inherits from Exception) o ExceptionB (which inherits from ExceptionA) Write an application named Test2 with these classes included. Create try blocks that throw exceptions of types: o ExceptionA o ExceptionB o NullPointerException o IOException Write a catch block for each try block specifying type Exception. Sample output is shown below. Additional Requirements Follow the Basic Coding Standards. Include a comment section at the top of your program with your student ID, name, and title of the program.

Sample Skeleton of Test 1 and Test 2 Classes // Student ID and name // Test1.java // Catching subclass exceptions public class Test1 { // The header of your executing main method goes here. { // Place your two try-catch blocks here. } } // end class Test1 // Place your exception subclasses (with empty bodies) here. // Student ID and name // Catching Exception exceptions // place an import statement here to catch input/output exceptions. public class Test2 { // The header of your executing main method goes here. { // Place your four try-catch blocks here. } } // end class Test1 // Place your two subclasses (with empty bodies) here.

Sample Output TEST1 First Exception subclass caught. Second Exception subclass caught. TEST2 ExceptionA ExceptionB java.lang.NullPointerException java.io.IOException

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

Making Databases Work The Pragmatic Wisdom Of Michael Stonebraker

Authors: Michael L. Brodie

1st Edition

1947487167, 978-1947487161

More Books

Students also viewed these Databases questions