Exercise 1.5: Change the HelloWorld application to use a named string constant as the string to print. (A
string constant can be initialized with a string literal.) 8
Exercise 1.6: Change your program from Exercise 1.3 to use a named string constant for the title. 8
Exercise 1.7: Change the loop in ImprovedFibonacci so that i counts backward instead of forward. 12
Exercise 1.8: Add a method to the Point class that sets the current object's coordinates to those of a passed
in Point object. 17
Exercise 1.9: Modify the Fibonacci application to store the sequence into an array and print the list of
values at the end. 20
Exercise 1.10: Modify the ImprovedFibonacci application to store its sequence in an array. Do this by
creating a new class to hold both the value and a boolean value that says whether the value is even, and
then having an array of object references to objects of that class. 20
Exercise 1.11: Modify the StringsDemo application to use different strings. 23
Exercise 1.12: Modify ImprovedFibonacci to store the String objects it creates into an array instead
of invoking println with them directly. 23
Exercise 1.13: Rewrite the ImprovedFibonacci program using printf instead of println. 24
Exercise 1.14: Sketch out a set of classes that reflects the class structure of the Sony Walkman product family
we have described. Use methods to hide the data, making all the data private and the methods public.
What methods would belong in the Walkman class? Which methods would be added for which extended
classes? 27
Exercise 1.15: Write an interface that extends Lookup to declare add and remove methods. Implement the
extended interface in a new class. 29
Exercise 1.16: Add fields to BadDataSetException to hold the set name and the I/O exception that
signaled the problem so that whoever catches the exception will know details about the error. 35
Exercise 2.1: Write a simple Vehicle class that has fields for (at least) current speed, current direction in
degrees, and owner name. 44
Exercise 2.2: Write a LinkedList class that has a field of type Object and a reference to the next
LinkedList element in the list. 44
Exercise 2.3: Add a static field to your Vehicle class to hold the next vehicle identification number, and a
non-static field to the Vehicle class to hold each car's ID number. 46
Exercise 2.4: Consider your solution to Exercise 2.3. Do you think the identification number field should be
final? 47
Exercise 2.5: Write a main method for your Vehicle class that creates a few vehicles and prints their field
values. 50
Exercise 2.6: Write a main method for your LinkedList class that creates a few objects of type Vehicle
and places them into successive nodes in the list. 50
Exercise 2.7: Add two constructors to Vehicle: a no-arg constructor and one that takes an initial owner's