2. When is an exception thrown or raised?
An exception is raised when its associated event occurs.
3. What are the advantages of having support for exception handling builtin to language?
– First, without exception handling, the code required to detect error conditions can considerably clutter a program.
– Another advantage of language support for exception handling results from exception propagation. Exception propagation allows an exception raised in one program unit to be handled in some other unit in its dynamic or static ancestry.
• A language that supports exception handling encourages its users to consider all of the events that could occur during program execution and how they can be handled. This approach is far better than not considering such possibilities and simply hoping nothing will go wrong.
4. Give an example of hardware-detectable execution.
One of the example of hardware-detectable execution is division by zero which naturally results in error.
6. What is exception propagation in Ada ?
Exception propagation in Ada is a powerful tool for constructing a more reliable software systems.
8. Where does execution continue after an exception is handled in Ada ?
Control will continue after the exception clause.
12. What is the use of Suppress pragma in Ada?
The suppress pragma is used to disable certain run-time checks that are parts of the built-in exceptions in Ada.
14. What is the name of all C++ exception handlers?
The name of all C++ exception handlers is Try clause.
15. Which standard libraries define and throw the exception out_of_range in C++?
The exception out_of_range is thrown by library container classes.
30. In which version were assertions added to Java?
Assertions were added to Java in version 1.4.
31. What is the use of the assert statement?
The assert statement is used for defensive programming. A program may be written with many assert statements, which ensure that the program’s computation is on track to produce correct results.
2. Describe the approach for the detection of subscript range errors used in C and Java.
In C subscript ranges are not checked. Java compilers usually generate code to check the correctness of every subscript expression. If any exception generates, then an unchecked exception is thrown.
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.