CPE 101 Assignment 5

Read Chapter 11 and do the following exercises.

  1. What is a cloneable class? Download the zip file clone.zip and run the CloneTest demo program with its associated Point class. Notice that setting r = p makes them refer to the same instance. Changing r is the same as changing p. Are the hashcodes of p and r the same? Note that unless a class implements the Cloneable interface, the clone method will throw an exception. Remove the comment in front of implements Cloneable. How does the output change? Point q is now a clone of Point p. Do they have the same hash codes?

  2. Do exercises 11.4 - 11.7 inclusive.

  3. Do one of 11.8 through 11.11.

  4. Do exercise 11.12

  5. Do exercises 11.14 and 11.16

  6. Do exercise 11.18

  7. Modify Fig 11.26 to allow items to be moved (rather than copied) from the left list to the right list and back again. The example below shows a suitable GUI. This happens to be an applet. You will be doing an application.

Maintained by John Loomis, last updated 22 Sept 2005