Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(JAVA) EXCEPTION HANDLING EX-1: Create a user defined exception sub class that accepts an integer in its constructor. Extend the Exception class Have a private

(JAVA) EXCEPTION HANDLING EX-1: Create a user defined exception sub class that accepts an integer in its constructor. Extend the Exception class Have a private value that is initialized by the constructor Override toString to display a custom message that uses the private value. In a main method: Use two text files, file1 and file2, to invoke your exception (via file1) and a general exception (via file2). Access the files using a method discussed in chapter 13 o Prompt the user to Enter 1 or 2 for which file they want to use for a given run. Use a try with resources block to access the file selected and trigger the exception. o For a general exception, you can force it or simply throw it directly yourself. Catch your exception and issue a message. Catch a general (nonspecific) exception and issue a message, then rethrow a general exception. Use a finally clause to issue a closing message.

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

The Database Experts Guide To Database 2

Authors: Bruce L. Larson

1st Edition

0070232679, 978-0070232679

More Books

Students also viewed these Databases questions

Question

What tools might be helpful?

Answered: 1 week ago