Reusing Classes

Exercises


  1. All classes automatically inherit from the class Object even if no extends clause is given. Look into your class documentation for the class Object (in package java.lang). Write a class InheritanceTest with no methods (except main) and no data members. Check, if you can use the method toString inherited from the class Object. What is its output?
  2. In the next exercises it is your task to model buildings. Each building has a door as one of its components. Write a class Door for this purpose:
  3. Define a Class Building for building objects.
  4. Extend exercise 3 by introducing a subclass HighBuilding.
  5. Define a subclass Skyscraper of HighBuilding:

Software Systems Institute

Home of the Java Course Claudia Niederée, nov 1999