CIT 591 First Quiz
Fall 2001, Dave Matuszek
Name   Answer Key

Please keep all answers short and legible. Do not volunteer information that was not asked for. Where appropriate, distinguish clearly between capital letters and lowercase letters.

  1. What keyword tells Java that your class is a subclass of some other class? extends

  2. The primitive type boolean has exactly two values, true and false.

  3. In BlueJ, what does it mean when a class is striped?

    It has not been compiled in its present form


  4. What happens if your program is running in BlueJ and you click on the turning red-and-white striped "candy cane" progress bar?

    The Debugger window opens. (Contrary to what many people thought, the program does not stop.)


  5. Rewrite the following names as they should be written in Java. Distinguish clearly between capital letters and lowercase letters.
    1. The boolean variable door_is_open   doorIsOpen

    2. The method openthedoor   openTheDoor

    3. The class garagedoor   GarageDoor

    4. The object variable my_garagedoor   myGarageDoor

  6. In Java, we don't call a function, we send a message to an object .

  7. True (T) or false (F):
    1. F   A class inherits the fields, methods, and constructors of its superclass.
    2. T    The declaration int i causes space to be allocated for an integer variable.
    3. T    The declaration String s does not cause space to be allocated for a String variable.
    4. F    When indenting Java statements, you should use hard tabs instead of soft tabs.
    5. F    When drawing in Java, the (0, 0) point is the bottom left-hand corner.
    6. T    { } is a legal statement in Java.

  8. Each of the following statements contains a syntax error. Very briefly, tell what is wrong with each statement.

    1. if (x - 1) y = 2 * x;     x - 1 is not a boolean expression
       
    2. while (x > y) { x--; y++ }    missing semicolon after y++
       
    3. for (int i = 0; i++; i < 10)    test and increment are in wrong order
           System.out.println(i);

       
    4. If (m < 0) m = -m;   keyword if should not be capitalized