CIT594 First Quiz
Fall, 2003

Please answer all questions briefly and to the point. You have plenty of room for correct answers.

Part I: Eclipse (30 points)

  1. (3 points) What happens when you double-click a line number in the Eclipse editor?

  2. (3 points) What happens when you select a method name and hit F2?

  3. (3 points) What happens when you double-click a method name in the Package Explorer view?

  4. (3 points) How do you compare the current version of a method with an earlier version?

  5. (3 points) Tell one way you can add a task to the Tasks view.

  6. (3 points) Tell one way you can invoke the Eclipse code formatter.

  7. (3 points) What happens if you type the name of an object, then a period, then hit control-space?

  8. (2 points) Rename... is one refactoring provided by Eclipse. Name another.

  9. (3 points) Name one perspective other than the Java Perspective.

  10. (4 points) In the Package Explorer view, what is indicated by a green circle? By a red square?

Part II: JUnit (12 points)
  1. (2 points) When you compare two objects with assertEquals(___, ___), which object should be first?

  2. (3 points) Name (don't describe) three different JUnit "assert..." test methods (other than assertEquals).

  3. (3 points) Every JUnit test method has two versions, one with an optional first parameter. What is that first parameter?

  4. (4 points) What is the JUnit setUp() method used for?

Part III: Data Structures (58 points)
  1. (6 points) Write a BNF rule or rules to recognize strings of balanced parentheses, such as (), ((())), and (()(())). Unbalanced strings should be rejected. You can assume the strings contain no other characters but parentheses.

  2. (6 points) Mark each of the following as either a class (C) or an interface (I):

    Set TreeSet Iterator
    Stack Comparator Comparable

  3. (8 points) Name (don't describe) four methods declared in the Collections interface.

  4. (6 points) Name (don't describe) the three methods declared in the Iterator interface.

  5. (4 points) Put the following in order, best to worst: O(n2), O(2n), O(n), O(1), O(log n), O(n log n).


  6. (5 points) How long (big O notation) do you expect the following method to take, given a completely random array? Briefly explain your answer.
    static int getIt(int[] a) {
        int target = a[0];
        for (int i = 1; i < a.length; i++) {
            if (a[i] > target) return i;
        return -1;
  7. (8 points) State Dr. Dave's four rules for doing recursion.

  8. (3 points) In what order would you visit the nodes of the following binary tree:

    1. In preorder?

    2. In inorder?

    3. In postorder?

  9. (6 points) Complete the following method to copy a binary tree (hint: 3 more lines needed):
    public BinaryTree copyTree(BinaryTree bt) {
        if (bt == null) return null;
  10. (6 points) Name the Set methods corresponding to:

    1. Set union

    2. Set intersection

    3. Set difference