CS 310, Object-Oriented Programming with Java

Quiz 3, 7 February 2008


  1. Explain how packages are involved in resolving the problem of a class having too many responsibilities.


    In general, classes with too many responsibilities should be broken up into component classes, each with a smaller set of responsibilities (Break up classes with too many responsibilities, page 149 (7th ed.) or 168 (8th ed.)). Each new class created has to be stored in some package (Addition of a Class into a Package, page 137 (7th ed.) or 155 (8th ed.)).

  2. What's the problem with finalization?


    It may not release resources quickly enough (Object Destruction and the finalize method, page 135 (7th ed.) or 152 (8th ed.)). The JVM guarantees only that the finalize method is called before a class instance is garbage collected. Scarce resources soon should be recovered soon after the class instance holding them becomes garbage, or, even better, once the resources are no longer needed, independent of whether or not the associated class instance is still valid.


This page last modified on 31 March 2008.