
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
this is a java

Transcribed Image Text:PART I:
Create an exception hierarchy of ExceptionA, ExceptionB and ExceptionC such that ExceptionB
inherits from ExceptionA and ExceptionC inherits from ExceptionB. Write a test program
to show that the catch block for supertype exception (ExceptionA) can catch all the subtype ex-
ceptions (ExceptionB and ExceptionC). Print out a message such as "ExceptionB caught" to
indicate which type of exception is caught. Name your class file as ExceptionHierarchy.java.
Hints:
1. To build the exception hierarchy, ExceptionA, ExceptionB and ExceptionC may have
empty body.
2. You may use System.err.println("ExceptionB caught"); instead of
System.out.println("ExceptionB caught"); so that the message will be output in
red color and in the format of exception messages. This is a more common way to output error
messages.
PART II:
Use the exception hierarchy from PART I to demonstrate that the order of catch block is important
if you want to specifically catch every exception in the same hierarchy. In other words, now you
should be able to catch subtype exceptions (ExceptionB and ExceptionC) separately rather
than using one catch block of supertype exception (ExceptionA) as you did in PART I.
You should define a method called some Method () that can throw all three exceptions randomly.
To do this, generate a random integer of 1, 2 or 3 representing ExceptionA, ExceptionB or
ExceptionC respectively, and then throw the corresponding exception. Output the random number
in some Method () to show which type of exception is randomly generated. Invoke some Method ()
in your test program and catch all three exceptions separately in three catch blocks. In each catch
block, print out a message such as "ExceptionA caught" to indicate which type of exception is
caught. Run your program a few times to make sure that some Method () may throw different
exception for different run and you are able to catch all three types of exceptions. Name your class
file as CatchDifferentExceptions. java.
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 4 steps with 6 images

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- how to assign a student an ID number and print it when asked in JAVA can you give me an example if there are several students and I enter a specific student ID it shows me their first name last name and agearrow_forwardTrue or False: JavaScript is the same language as Javaarrow_forwardplease answer this in javaarrow_forward
- python multiple choice Code Example 4-1 def get_username(first, last): s = first + "." + last return s.lower() def main(): first_name = input("Enter your first name: ") last_name = input("Enter your last name: ") username = get_username(first_name, last_name) print("Your username is: " + username) main() 5. Refer to Code Example 4-1: What is the scope of the variable named s ?a. globalb. localc. global in main() but local in get_username()d. local in main() but global in get_username()arrow_forwardCoding in python Please!!I need help please help me in the easiest way to do this coding question. Please do not post it's answer from chegg just use your own skills to write code in easyiest way possible. I will really appriciate your help. Coding language PYTHON : The purpose of this assignment is to help you get comfortable creating and using simple classes and objects. In this assignment, we wish to model a 2-D video game character’s movements. In particular, suppose we are creating a tiny game, where the character can occupy one of 25 squares, like so: The first thing we need to keep track of is the character’s name, so we can differentiate this character from other characters or enemies. The other thing we need to keep track of is the character’s position, i.e., which square they are in. In order to do this, we’ll use an X-Y coordinate system with the origin in the top left corner (the 0,0 square in the picture). So, in the picture, the character occupies square 3, 2;…arrow_forwardJava - Smallest Numberarrow_forward
- Asking help for Java Programming Create a program that simulates a meeting reservation system. Part 1: Basic requirements The program shall allow the user to select from the following options: Create a new meeting Show meetings on the calendar Clear all meetings Each meeting has a subject, start day/time and end day/time Subject is a short text description of the meeting Day is a date that contains month, day, and year Meeting times need only deal with hour and minute When the user wants to create a new meeting, the program asks for the subject, start and end day/times for it and adds it to the calendar For the basic requirements, meetings are not allowed to overlap. If a meeting the user wants to schedule overlaps with an existing meeting, the program presents an error message showing which meeting the one the user wants to schedule overlaps with When the user wants to show all meetings for the week, the report displays all meetings each day as follows Show all meetings…arrow_forwardFill in the proper blank. JDB is used for finding and fixing ____ inside the Java program.arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education