For homework, I have to develop an exceptions code:
“Use inheritance to create a superclass of exception called ExceptionA, and two subclasses of the exception called ExceptionB and ExceptionC, where ExceptionB extends ExceptionA, and ExceptionC extends ExceptionB. Develop a program to prove that the catch block for the type ExceptionA catches exceptions of ExceptionB and ExceptionC“.
I do not understand how to do this.
Here is a very simple code. You can further enhance for your learning.
Create exception
ExceptionAand define require constructors and methods:Create exception
ExceptionBand define require constructors and methods:Create exception
ExceptionCand define require constructors and methods:Create
TestExceptionclass which catchesExceptionBandExceptionCusingExceptionAas below: