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

Exercises

  1. Write a method that takes an object and recursively prints all the classes in that object’s hierarchy.
  2. In ToyTest.java, comment out Toy’s default constructor and explain what happens.
  3. Create a new type of collection that uses a Vector. Capture the type of the first object you put in it, and then allow the user to insert objects of only that type from then on.
  4. Write a program to determine whether an array of char is a primitive type or a true object.
  5. Implement clearSpitValve( ) as described in this chapter.
  6. Implement the rotate(Shape) method described in this chapter, such that it checks to see if it is rotating a Circle (and, if so, doesn’t perform the operation).
^

Contents | Prev | Next