CIT 591 Makeup Quiz
Fall 2001, Dave Matuszek
Name __________________________________

All answers must be kept brief. Points will be taken off for unnecessarily long or detailed answers.

  1. Elegance is a combination of what two properties?          power and simplicity (from very first lecture!)

  2. What package would you import in order to:
    1. Draw pictures on the screen?          java.awt

    2. Put Panels and Buttons on the screen?          java.awt

    3. Respond to button clicks?          java.awt.event

    4. Use wrappers for primitives?          java.lang (does not need to be imported explicitly)

    5. Use Vectors?          java.util

  3. It is possible to write an Applet without using any import statements at all. Briefly, what must you do instead if you don't have import statements?
              Use fully qualified names

  4. BlueJ's debugger is itself buggy. Briefly describe one bug in the debugger.
              Doesn't display values of static variables
              Breakpoints cannot be set in inner classes
              Removing breakpoints does not always work
              BlueJ thinks terminated programs are still running

  5. What is the type of 3.1416?          double


  6. What does the continue statement do?          return to the top of the enclosing loop


  7. Why shouldn't you use hard tabs?          different systems use different numbers of spaces to represent hard tabs


  8. Define a (correctly named) setter method for an int variable named voltage.
              public void setVoltage(int voltage) {
                   this.voltage = voltage;
              }


  9. Very briefly, mention the two ways of fixing a broken constructor chain.
              1. Define a no-argument constructor for the superclass
              2. Explicitly call a superclass constructor in the subclass constructor


  10. Where is the one place that it is usually better not to use a meaningful name for a variable?
              As the index of a for loop

  11. Java uses six namespaces. Name three of them.
              Any three of: package names, type names, field names, method names, local variable names, labels

  12. If a variable name is protected, from where can it be accessed?
              Anywhere within the same directory, and from any subclass

  13. What Java construct (that is, what syntax) must you use in order to do narrowing?
              A cast

  14. What is the difference between & and && when applied to boolean operands?
              && does short-circuit evaluation; & evaluates both operands

  15. There is an error in the following method. Fix it.

            public String toString() {
                        return this.name;
                   }


  16. Which kind of layout manager will make all components the same size?          GridLayout


  17. What two kinds of things may be in an interface?          method declarations, constant definitions


  18. .java files are compiled into .class files. What distinguishes the name of a compiled inner class file from that of other class files?
              Their names contain the $ character

  19. The primary purpose for documentation comments is to define a   contract   between a client and a supplier of a service.

  20. What two things does the HTML <pre> tag do?
              1. Preserves whitespace
              2. Puts text into a monospaced font

  21. In one line, declare and define an array faceCards containing the three strings "Jack", "Queen", and "King".
              String faceCards[] = {"Jack", "Queen", "King"};

  22. State the Open-Closed Principle.
              Classes should be open for extension, but closed for modification. (Rule 70)


  23. Every constructor for a FileDialog requires a   Frame   as its first argument.

  24. What are the two approaches to multiprocessing on a single processor computer?
              cooperative multiprocessing
              preemptive multiprocessing

  25. Draw a pure state machine that tests whether a binary number is even or odd.
               __            __
            0 |  |        0 |  |
              |  V          |  V
             ______  1     ______
            |      |----->|      |
            | even |      | odd  |
   start -->|      |<-----|      |
            |______|    1 |______|