Quiz 10

Wednesday

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

  1. There are exceptions that inherit from the Error class or the RuntimeException class. What are these exceptions called?

    1. unrecoverable exceptions
    2. unchecked exceptions
    3. recoverable exceptions
    4. checked exceptions
  2. Is the following statement correct, and why?

    IOException serves as a superclass for exceptions that are related to programming errors, such as an out-of-bounds array subscript.

    Answer: False, RuntimeException serves as a superclass for exceptions that are related to programming errors, such as an out-of-bounds array subscript.

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

    // create my own exception class by 
    // deriving it from the Exception class.
    class MyException {
      public MyException(String message) {
        super("My Exception: " + message);
      }
    }

    Correction:

    // create my own exception class by 
    // deriving it from the Exception class.
    class MyException extends Exception {
      public MyException(String message) {
        super("My Exception: " + message);
      }
    }
  4. With the following class definitions...

    class ClassA {
    	public ClassA() {...}
    	public void method1() {...}
    }
    
    class ClassB extends ClassA {
    	public ClassB() {...}
    	public void method1() {...}
    }
    
    class ClassC extends ClassB {
    	public ClassC() {...}
    	public void method1() {...}
    }

    Are the following statements correct?

    Answer: Yes

    ClassA item = new ClassC();
    item.method1();

    If yes, which method1 will be executed?

    1. the one defined in ClassA
    2. the one defined in ClassB
    3. the one defined in ClassC

Student Performance and Statistics

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

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

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

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