Quiz 6

Friday

With a piece of paper, write down your name and answers to the following questions.

  1. What is one of the methods that are common to both the String and the StringBuilder classes?

    1. length
    2. insert
    3. append
    4. delete
  2. The isLetter, isDigit, and isUpperCase methods are members of which class?

    1. Char
    2. Character
    3. StringBuilder
    4. String
  3. These static final variables are members of the numeric wrapper classes, and they hold the minimum and maximum values for a particular data type. What are they?

    1. MIN_VALUE and MAX_VALUE
    2. MIN and MAX
    3. MINIMUM and MAXIMUM
    4. LOWEST and HIGHEST
  4. Is the following statement correct, and why?

    To use a numeric wrapper class, such as Character, you need to write the corresponding import statement.

    Answer: False, first, the Character wrapper class is not numeric; second, wrapper classes are part of the java.lang package, so there is no need for an import statement.

  5. Find and correct the error in the following program.

    import java.util.StringTokenizer;

    public class Program {
      public static void main(final String[] args) {

        // Tokenize a string that is delimited with semicolons.  This
        // string contains three tokens: "one", "two", and "three".
        StringTokenizer tokenizer = new StringTokenizer("one;two;three");

        while (tokenizer.hasMoreTokens())
          System.out.println(tokenizer.nextToken());
      }
    }

    Correction:

    import java.util.StringTokenizer;

    public class Program {
      public static void main(final String[] args) {

        // Tokenize a string that is delimited with semicolons.  This
        // string contains three tokens: "one", "two", and "three".
        StringTokenizer tokenizer = new StringTokenizer("one;two;three", ";");

        while (tokenizer.hasMoreTokens())
          System.out.println(tokenizer.nextToken());
      }
    }

    Or:

    import java.util.StringTokenizer;

    public class Program {
      public static void main(final String[] args) {

        // Tokenize a string that is delimited with spaces.  This
        // string contains three tokens: "one", "two", and "three".
        StringTokenizer tokenizer = new StringTokenizer("one two three");

        while (tokenizer.hasMoreTokens())
          System.out.println(tokenizer.nextToken());
      }
    }

Student Performance and Statistics

A histogram of student performance on percentage grades for Quiz 6 on Friday.

100% 4 90 - 99% 0 80 - 89% 4 70 - 79% 0 60 - 69% 2 50 - 59% 0 40 - 49% 0 30 - 39% 0 20 - 29% 1 10 - 19% 0 0 - 9% 1

A table showing the average performance for each question in Quiz 6 on Friday.

Q1 0.7 / 1 Q2 0.9 / 1 Q3 0.8 / 1 Q4 0.8 / 1 Q5 0.4 / 1