CIT 594 Third Quiz
Spring 2002, Dave Matuszek
Name __________________________________________
  1. (5 points) What does the acronym DRY stand for? (Three words)
         Don't Repeat Yourself!

  2. (15 points) What three things characterize a data type?
         A set of values
         A data representation of those values
         A set of operations


  3. (5 points) What one characteristic of a data type should not be specified in an ADT?
         The data representation

  4. (5 points) Very briefly, tell what it means for a class to be cohesive.
         It has a single, well-defined purpose; it represents a single, unified concept

  5. (5 points) Very briefly, tell what it means for classes to be loosely coupled.
         A change in one class requires few or no changes in other classes

  6. (10 points) Write the complete Java code for a setter for a double variable named debt.
         public void setDebt(double debt) {
              this.debt = debt;
         }

  7. (10 points) (Complete the sentences) For an ADT,
    1. The constructors and transformers must together be able to
           create all legal values of the ADT needed by the application

    2. The accessors must be able to
           extract any data needed by the application

  8. (10 points) Name the two kinds of transformers, and briefly tell which is which.
         mutative -- changes the value of the ADT it is given
         applicative -- takes one ADT and, without changing it, returns a new ADT


  9. (10 points) Write a complete main method (and nothing more) for a class Opus, so that "static poisoning" will not occur. Assume the existence of any other methods you need.
         public static void main(String args[]) {
              Opus myOpus = new Opus();
              myOpus.doAllTheWork();
         }
  10. (25 points) Write the signatures (complete headers) for the five main methods of the java.util.Stack class. Do not explain these methods.
         public Object push(Object obj)
         public Object pop()
         public Object peek()
         public boolean empty()
         public int search(Object obj)