Bruce Eckel's Thinking in Java Contents | Prev | Next

Exercises

  1. Create an inheritance hierarchy of Rodent: Mouse, Gerbil, Hamster, etc. In the base class, provide methods that are common to all Rodents, and override these in the derived classes to perform different behaviors depending on the specific type of Rodent. Create an array of Rodent, fill it with different specific types of Rodents, and call your base-class methods to see what happens.
  2. Change Exercise 1 so that Rodent is an interface.
  3. Repair the problem in WindError.java.
  4. In GreenhouseControls.java, add Event inner classes that turn fans on and off.
7

Contents | Prev | Next