Java Reference
In-Depth Information
Exercise R11.5. Give two examples of programs on your computer that
read arguments from the command line.
Exercise R11.6. If a program Woozle is started with the command
java Woozle-Dname=piglet -I\eeyore -v heff.txt
a.txt lump.txt
what are the values of
args[0]
,
args[1]
, and so on?
Exercise R11.7. What is the difference between throwing an exception and
catching an exception?
Exercise R11.8. What is a checked exception? What is an unchecked
exception? Is a
NullPointerException
checked or unchecked?
Which exceptions do you need to declare with the
throws
keyword?
Exercise R11.9. Why don't you need to declare that your method might
throw a
NullPointerException
?
522
523
Exercise R11.10. When your program executes a
throw
statement, which
statement is executed next?
Exercise R11.11. What happens if an exception does not have a matching
catch
clause?
Exercise R11.12. What can your program do with the exception object that
a
catch
clause receives?
Exercise R11.13. Is the type of the exception object always the same as the
type declared in the
catch
clause that catches it?
Exercise R11.14. What kind of values can you throw? Can you throw a
string? An integer?
Exercise R11.15. What is the purpose of the
finally
clause? Give an
example of how it can be used.
Exercise R11.16. What happens when an exception is thrown, the code
of a
finally
clause executes, and that code throws an exception of a