Java Reference
In-Depth Information
In the fragment, a superclass catch precedes a subclass catch . Since the superclass
catch will catch all subclasses too, unreachable code is created.
6 . Can an inner catch rethrow an exception to an outer catch ?
Yes, an exception can be rethrown.
7 . The finally block is the last bit of code executed before your program ends. True or
False? Explain your answer.
False. The finally block is the code executed when a try block ends.
8 . What type of exceptions must be explicitly declared in a throws clause of a method?
All exceptions except those of type RuntimeException and Error must be declared
in a throws clause.
9 . What is wrong with this fragment?
MyClass does not extend Throwable . Only subclasses of Throwable can be thrown
by throw .
10 . In question 3 of the Chapter 6 Self Test, you created a Stack class. Add custom ex-
ceptions to your class that report stack full and stack empty conditions.
Search WWH ::




Custom Search