Friday, June 28, 2013

KBP - Chapter 14

Review Question

2. An exception is raised when its associated event occurs.

3. Advantages to having exception handling built into a language :
Without exception handling, the code required to detect error conditions can considerably clutter a program, save development costs, program size, and program complexity
7. All of them are gathered together in an exception clause.

10. Four exceptions defined in the default package, Standard :
  - Constraint_Error
  - Program_Error
  - Storage_Error
  - Tasking_Error

12. Disabling run-time checks

15. Container classes.

18. After a handler has completed its execution, control flows to the first statement following the try construct

Problem Set

1. The early programming languages, when the error occurs, the error is transferred to the operating system. The typical OS reaction to a run-time error is to display a diagnostic message.
2. Java compilers usually generate code to check the correctness of every subscript expression. In C subscript ranges are not checked because the cost of such checking was not believed to be worth the benefit of detecting such errors
4.   What are the different approaches to handle checked exception in Java?

In Java there are basically two types of exceptions: Checked exceptions and unchecked exceptions.

Checked exceptions must be explicitly caught or propagated as described in Basic try-catch-finally Exception Handling. Unchecked exceptions do not have this requirement. They don’t have to be caught or declared thrown.
Checked exceptions in Java extend the java.lang.Exception class. Unchecked exceptions extend the java.lang.RuntimeException.

14.  Summarize the arguments in favor of the termination and resumption models of continuation.

The resumption model is useful when the exception is only an unusual condition, rather than an error. The termination model is useful when the exception is an error and it is highly unlikely that the error can be corrected so that execution could continue in some useful way.

No comments:

Post a Comment