Question: Write a program that demonstrates how various exceptions are caught with catch (Exception exception) Define classes ExceptionA (which inherits from class Exception) and ExceptionB (which

 Write a program that demonstrates how various exceptions are caught with

Write a program that demonstrates how various exceptions are caught with catch (Exception exception) Define classes ExceptionA (which inherits from class Exception) and ExceptionB (which inherits from class ExceptionA). In your program, create try blocks that throw exceptions of types ExceptionA, ExceptionB and IOException. All exceptions should be caught with catch blocks specifying type Exception. Next, develop individual catch handlers for subclasses ExceptionA and ExceptionB. Demonstrate that the order of catch blocks is important. If you try to catch a superclass exception type before a subclass type, the compiler should generate errors

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!