Java Reference
In-Depth Information
Exercises
Visit
www.myprogramminglab.com
to complete many of these Exercises
online and get instant feedback.
EX 11.1 Create a UML class diagram for the
ProductCodes
program.
EX 11.2 What would happen if the
try
statement were removed from the
level1
method of the
ExceptionScope
class in the
Propagation
program?
EX 11.3 What would happen if the
try
statement described in the previ-
ous exercise were moved to the
level2
method?
EX 11.4 Look up the following exception classes in the online Java API
documentation and describe their purpose:
a.
ArithmeticException
b.
NullPointerException
c.
NumberFormatException
d.
PatternSyntaxException
EX 11.5 Draw the containment hierarchy tree for the
LightBulb
program.
EX 11.6 Draw the containment hierarchy tree for the
PickImage
program.
EX 11.7 Draw the containment hierarchy tree for the
JukeBox
program.
EX 11.8 What effect would removing the call to
setSelectionMode
in the
ListPanel
class have? Make the change to test your answer.
Programming Projects
Visit
www.myprogramminglab.com
to complete many of these Programming
Projects online and get instant feedback.
PP 11.1 Design and implement a program that creates an exception class
called
StringTooLongException
, designed to be thrown when
a string is discovered that has too many characters in it. In the
main
driver of the program, read strings from the user until the
user enters
"DONE"
. If a string is entered that has too many char-
acters (say 20), throw the exception. Allow the thrown exception
to terminate the program.
PP 11.2 Modify the solution to PP 11.1 such that it catches and handles
the exception if it is thrown. Handle the exception by printing an
appropriate message, and then continue processing more strings.
VideoNote
Developing a solution
of PP 11.1.
Search WWH ::
Custom Search