Handling Exceptions - Quiz Explanation

The answers you selected are indicated below, along with text that explains the correct answers.
 
1. Which one of the following classes is associated with a normal exception, as opposed to a runtime exception?
Please select the best answer.
  A. FileNotFoundException
  B. IndexOutOfBoundsException
  C. ArithmeticException
  The correct answer is A. A FileNotFoundException object is thrown when a file isn't found, which is a normal exception. An IndexOutOfBoundsException object is thrown when an array is indexed beyond its bounds, which is a runtime exception. An ArithmeticException object is thrown in response to an arithmetic runtime exception such as a divide by zero.

2. Using the try-catch construct, you place the code that can potentially throw an exception in:
Please select the best answer.
  A. A catch block
  B. The finally block
  C. The try block
  The correct answer is C. Using the try-catch construct, you place the code that can potentially throw an exception in the try block. A catch block is executed when an exception is handled. The finally block contains code that is executed regardless of how the try block is left.

3. What method do you call on an Exception object to print the call stack associated with the exception?
Please select the best answer.
  A. printStackTrace()
  B. printCallStack()
  C. printTraceStack()
  The correct answer is A. You call the printStackTrace() method on an Exception object to print the call stack associated with the exception. There are no methods named printCallStack() and printTraceStack() defined in the Exception class.


4. What is commonly referred to as an exception handler?
Please select the best answer.
  A. A catch clause
  B. The try clause
  C. The throws clause in a method declaration
  The correct answer is A. A catch clause is commonly referred to as an exception handler. The try clause and the throws clause in a method declaration aren't referred to as exception handlers; exceptions are only handled in a catch clause.