Java Reference
In-Depth Information
6.
catch
(Exception thrownObject)
{
System.out.println(thrownObject.getMessage());
}
7.
thrownObject
8. Yes, it is legal.
9. Yes, it is legal.
10.
public class
PowerFailureException
extends
Exception
{
public
PowerFailureException()
{
super
("Power Failure!");
}
public
PowerFailureException(String message)
{
super
(message);
}
}
11.
public class
TooMuchStuffException
extends
Exception
{
public
TooMuchStuffException()
{
super
("Too much stuff!");
}
public
TooMuchStuffException(String message)
{
super
(message);
}
}
12.
ExerciseException invoked with an argument.
Do Be Do
13.
Test exception thrown!!
Test Exception thrown!
Message is Test Exception thrown!
14.
try block entered:
MyException: Hi Mom!
End of example.
15.
The output would be the same.