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...

If we were to call the MakeDouble and ChangeArg methods shown below, using the following statements, what value would be assigned to lblResult.Text?

``` Dim intValue As Integer = 20 ChangeArg(intValue) lblResult.Text = MakeDouble(intValue).ToString() Function MakeDouble (ByVal intArg As Integer) As Integer Return intArg * 2 End Function Sub ChangeArg2(ByRef intArg As Integer) ' Display the value of intArg. lstOutput.Items.Add(" ") lstOutput.Items.Add("Inside the ChangeArg procedure, " & "intArg is " & intArg.ToString()) lstOutput.Items.Add("I will change the value of intArg.") ' Assign 0 to intArg. intArg = 0 ' Display the value of intArg. lstOutput.Items.Add("intArg is now " & intArg.ToString()) lstOutput End Sub ``` a. 0 b. 20 c. 40 d. (cannot be determined)

Computer Science & Information Technology

The command to count number of lines in xyz is

a: wc count xyz b: line count xyz c: count l xyz d: wc l xyz e: wc lines xyz

Computer Science & Information Technology

Another word for reflecting is ____.

A. rotating B. flipping C. thinking D. mirroring

Computer Science & Information Technology

The Sum button is located in the ____ group on the Home tab of the Ribbon.

A. Commands B. Formulas C. Editing D. Data

Computer Science & Information Technology