Quiz 9

Wednesday

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

  1. Which of the following class does all exception classes inherit from?

    1. Error
    2. RuntimeException
    3. Throwable
    4. JavaException
  2. Which method can be used to retrieve the error message from an exception object?

    1. errorMessage
    2. errorString
    3. getError
    4. getMessage
  3. Is the following statement correct, and why?

    Regardless of whether an exception is thrown by code inside of a try block, all statements in the try block are always executed.

    Answer: False, the normal execution of the try block would be interrupted when an exception is thrown.

  4. Find and correct the error in the following code.

    // assume inputFile references to a Scanner object.
    try {
    	input = inputFile.nextInt();
    
    } finally {
    	inputFile.close();
    
    } catch (inputMismatchexception e) {
    	System.err.println("Input Mismatch");
    }

    Correction:

    // assume inputFile references to a Scanner object.
    try {
    	input = inputFile.nextInt();
    
    } catch (inputMismatchexception e) {
    	System.err.println("Input Mismatch");
    
    } finally {
    	inputFile.close();
    }

Student Performance and Statistics

A histogram of student performance on percentage grades for Quiz 9 on Wednesday.

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

A table showing the average performance for each question in Quiz 9 on Wednesday.

Q1 0.9 / 1 Q2 1.0 / 1 Q3 0.6 / 1 Q4 0.8 / 1