1. See the section "Exceptions and Exception Types." The Throwable class is the root of Java exception classes. Error and Exception are subclasses of Throwable. Error describes fatal system errors, and Exception describes the errors that can be handled by Java programs. The subclasses of Error are LinkageError, VirtualMachineError, and AWTError. The subclasses of Exception include RuntimeException, IOException, AWTException, and InstantiationException.
2. The purpose of claiming exceptions is to tell the Java runtime system what can go wrong. You claim an exception using the throws keyword in the method declaration. You can claim multiple exceptions, separated by commas.
3. You use the throw statement in the method to throw an exception. You cannot throw multiple exceptions in a single throw statement.
4. throw is for throwing exceptions and throws is for claiming exceptions.
5. When an exception occurs, the Java runtime system creates an object for the exception, and the catch process starts.
6. Use a try-catch block to catch exceptions.
7. No.
8. Will statement3 be executed?
Answer: No.
If the exception is not caught, will statement4 be executed?
Answer: No.
If the exception is caught in the catch clause, will statement4 be executed?
Answer: Yes.
If the exception is passed to the caller, will statement4 be executed?
Answer: No.
9. Will statement5 be executed if the exception is not caught?
Answer: No.
If the exception is of type Exception3, will statement4 be executed? Will statement5 be executed?
Answer: This exception is caught by the catch (Exception3 e3) clause and statement4 will be executed, but statement5 will not be executed because it is rethrown to its caller.
10. It does not have a catch clause.
11. Welcome to Java
The finally clause is executed
12. Welcome to Java
The finally clause is executed
Note: the finally clause is always executed!
13. Welcome to Java
The finally clause is executed
14. Welcome to Java
Welcome to HTML
The finally clause is executed
15. Welcome to Java
RuntimeException caught
The finally clause is executed
16. Welcome to Java
Welcome to HTML
The finally clause is executed
End of Block
17. Welcome to Java
The finally clause is executed
End of Block
18. RuntimeException is a subclass of Exception. Therefore, RuntimeException should be caught before Exception.
19. Rational operation error
20. Rational operation error
21. Rational operation error
After the method call
22. Rational operation error
Rational operation error
23. If an exception were not caught in a non-GUI application, the program would terminate. If an exception were not caught in a GUI application, the program would continue and the error message would be reported on the console.
24. To print trace information to the console.