Java Exception Basics - Quiz Explanation

The answers you selected are indicated below, along with text that explains the correct answers.
 
1. Which of the following occurrences fails to qualify as an exception?
Please select the best answer.
  A. A file is not found.
  B. A network connection fails.
  C. An infinite loop is entered.
  The correct answer is C. An infinite loop fails to qualify as an exception because it is either a programming error or an intended result.

2. What standard class is derived from Throwable and serves as the base class for normal Java exceptions?
Please select the best answer.
  A. RuntimeException
  B. Exception
  C. Error
  The correct answer is B. The Exception class is derived from Throwable and serves as the base class for normal Java exceptions. The RuntimeException class serves as the base class for runtime exceptions, not normal exceptions. The Error class serves as the base class for errors, not normal exceptions.


3. How do you indicate that the code in a method is capable of throwing an exception?
Please select the best answer.
  A. Use the throw keyword.
  B. Use the throws keyword.
  C. Create an Exception object and return it from the method.
  The correct answer is B. To indicate that the code in a method is capable of throwing an exception, you use the throws keyword. The throw keyword is used to actually throw an exception but not to designate a method as being capable of throwing an exception. The Exception object has nothing directly to do with designating a method as being capable of throwing an exception.