Answer the following statements true (T) or false (F)

1. In type matching to select a catch block, only exact matches work.
2. The situations where exceptions are used put the try block with the throw statement followed by the catch block all in one function.
3. A function that satisfies its preconditions but cannot fulfill its postconditions should throw an exception.
4. When an exception is thrown, the function finishes its execution, its value is returned, then control is transferred to the catch block.

1. True
If the catch block specifies double, an int will not be converted to select a double catch block.
2. False
Examples like this are unrealistically simple. It is far more reasonable to have exceptions thrown in some function (a library) where the situation can be detected and an exception thrown. The exception is handled in a calling function (perhaps in an application) where what to do to manage the situation can be understood so what to do is clear.
3. True
Typically the function runs into some error condition that prevents it from fulfilling its postcondition. This is the basis for throwing an exception.
4. False
When an exception is thrown in a function the throw statement throws an exception object, control and the exception object are transferred to a catch block some place up the call chain. The rest of the function is skipped. There is no return value. The exception is handled there.

Computer Science & Information Technology

You might also like to view...

A group of related files is called a ______.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology

A switchback form is a special form used to help users navigate throughout the rest of the database.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology