CS 101 (Spring 1999)
Quiz 9: Abstract Classes and Design

Quiz Posted
(Wednesdays)
Given in class
(Wednesdays)
31 Mar 7 Apr

Information about quizzes:

The questions are intended to be straightforward. If you keep up with the material in the class, almost no preparation may be necessary. The Collaboration Policy allows you to study in groups for the quizzes, but you are on your own when you take the quiz.

You will fare better on the quiz if you try working the problems before looking at the solutions. If you don't understand the question or its answer, please get help.

  1. Provide an abstract class Stack for a stack that includes the operations isEmpty, push, and pop (you may find that other methods are needed). In the abstract class, make pop non-abstract. It should throw an error if the stack is empty, otherwise do a "real pop".
  2. Subclass your Stack class into ListBasedStack that uses the List from class.
  3. Subclass your Stack class into QueueBasedStack that uses the Queue structure presented in class.
  4. Provide an abstract class for a Shape that includes methods for determinng the shape's area and circumference.
  5. Subclass your Shape class into Rectangle.
  6. Subclass your Rectangle class into Square.

[ solution ]


Last modified 11:35:29 CST 30 March 1999 by Ron K. Cytron