CS52 Chapter 16 - Quiz

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Functions may potentially throw at most one exception.

FALSE

Functions that might throw an exception must have a throw list.

FALSE

If a function throws an exception, it must be caught inside that function.

FALSE

In a try block, the throw statement is always executed.

FALSE

The braces are not necessary on a try block.

FALSE

The catch block is a function.

FALSE

It is legal to have a catch block with no parameter.

TRUE

The catch block is the group of statements that handle an exception.

TRUE

The following function does not throw any unhandled exceptions void f1( ) throw ( );

TRUE

The throw statement passes a value to the catch block.

TRUE

Which of the following would be a good reason for using inherited exception classes?

a derived class exception can be passed to an exception parameter of the base

The throw statement is enclosed in

a try block

A catch block that expects an integer argument will catch

all integer exceptions

Which type of exception is thrown if a call to the new operator fails?

bad_alloc

The following catch statement catch(...)

catches all exceptions

Which of the following code fragments are illegal? a. try { try { //other code here } catch(int e) { //code here } } catch(float e) { //code here } b. try { //code here } catch(int e) { //code here try { //code here } catch(string e) { } } c. All of the above d. None of the above

d. None of the above

A throw statement can throw a. an integer exception b. a float exception c. a bool exception d. an exception of any data type e. all of the above f. none of the above

e. all of the above

A class that is used for exceptions is declared a. differently from other classes b. specialized only for exceptions c. may not have objects declared of that class d. all of the above e. none of the above

e. none of the above

If a function will possibly throw an unhandled exception, the try block should

encompass the function call

When a throw statement is executed,

execution of the try block stops

The following class definition class MyError {};

has only a default constructor

If class A is derived from class B, and a virtual function in class B throws an exception, then the overridden version of that function in class A must

have an exception specification that is a subset of the exception specification of the base class B

The parameter in the catch statement

identifies what type of exceptions are caught

If a function throws an exception

it may be caught in that function

If you have a function that might throw an exception and some programs that use that function might want to handle that exception differently, you should

not catch the exception in the function

You should use exception handling

only when you can not handle the exception with simpler control structures

The block of code that handles an exception is called

the catch block

If the following function will throw a string exception, then void myFunction( );

the function definition and declaration should have a throw list

Given the following function definition, what happens if the function throws the exception? void f1( ) throw (double) { if( //some code here) throw 12; }

the function will cause the program to exit

The block of code that checks if an unusual situation or error occurs is called

the try block

When an unusual situation or error occurs, then the ________ statement is executed.

throw

Which of the following is not a valid reason for using exception handling?

throw and catch can be used like gotos

Which of the following function declaration correctly specifies that two types of exceptions are thrown

void f1( ) thaw (a,b);


संबंधित स्टडी सेट्स

Social Studies Chapter 14 Northern Europe

View Set

Matrices Vocabulary PreCal/TRIG Fall 2021

View Set

Linux+ Final Exam parts of Chapter 10-12

View Set

460 exam 2 lippincott eye ear disorder questions

View Set

(WK 3 NR 326) ECT Therapy questions

View Set