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

1. The situations where exceptions are used put the try block with the throw statement followed by the catch block all in one function.

2. A function that satisfies its preconditions but cannot fulfill its postconditions should throw an exception.


1. False
Explanation: 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.
2. True
Explanation: Typically the function runs into some error condition that prevents it from fulfilling its postcondition. This is the basis for throwing an exception.

Computer Science & Information Technology

You might also like to view...

Given the declarations below, write a code fragment that allocates a nameless variable for pointer p1 to point to.

``` int *p1, *p2; ```

Computer Science & Information Technology

Which of the following is false?

a) In any flowchart, any rectangle (action) can be replaced by 2 rectangle (actions) in sequence. b) In any flowchart, any rectangle (action) can be replaced by any control structure (sequence, if, if/else, switch, while, do/while or for). c) In any flowchart, control structure (sequence, if, if/else, switch, while, do/while or for) can be replaced by 2 rectangle (actions) in sequence. d) Connecting control structures in sequence is called control structure stacking

Computer Science & Information Technology

Case B-2Charles has created an illustration consisting mainly of ellipses. The illustration also consists of two identical sets of objects. Charles is ready to apply a new stroke color to each ellipse. Which of the following commands would he use to select all of the ellipses?

A. Select Same Stroke Weight B. Select Same Shape C. Select Same Stroke Color D. either a. or c.

Computer Science & Information Technology

You should wait until the normalization process is complete before creating relationships between tables

Indicate whether the statement is true or false

Computer Science & Information Technology