Computing III Packet 6

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

If a function will possibly throw an unhandled exception, the try block should A) encompass the function call. B) not be used. C) be in the function definition. D) be in the catch block.

A

If the following function will throw a string exception, then which is true? void myFunction( ); A) the function definition and declaration should have a throw list. B) the function should have an empty throw list. C) the function definition, but not the declaration, should have a throw list. D) all of the above

A

The following class definition class MyError { }; A) has only a default constructor. B) is illegal. C) has no member functions or member data. D) A and B

A

The parameter in the catch statement A) identifies what type of exceptions are caught. B) makes the catch block a function. C) must always be an e. D) identifies the different number of exceptions that can be caught.

A

What is the return type of the minmax_element generic algorithm? A) pair B) iterator C) T (generic type) D) bool

A

When a throw statement is executed, A) execution of the try block stops. B) the program always exits. C) execution of the catch block stops. D) execution of the throw block stops.

A

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 A) throw an integer exception. B) not catch the exception in the function. C) never throw an exception in this function. D) none of the above

B

The block of code that checks if an unusual situation or error occurs is called A) a function. B) the catch block. C) the try block. D) an error block.

B

The block of code that handles an exception is called A) a function. B) the catch block. C) the try block. D) an error block.

B

The throw statement is enclosed in A) a catch block. B) a try block. C) a throw block. D) quotes.

B

Which of the following function declaration correctly specifies that two types of exceptions are thrown? A) void f1( ) throw a, throw b; B) void f1( ) throw (a,b); C) void f1(exception a, exception b); D) void f1( ) exception (a;b);

B

Which of the following is not a valid reason for using exception handling? A) The procedure for handling an error depends on the situation. B) Throw and catch can be used like gotos. C) need to handle built in exceptions D) none of the above

B

A catch block that expects an integer argument will catch A) any exception value that can be coerced into an integer. B) all exceptions. C) all integer exceptions. D) none of the above

C

Given the following function definition, what happens if the function throws the exception? void f1( ) throw (double) { if( /* some code here */ ) throw 12; } A) This code has a syntax error. B) The 12 will be converted to 12.0. C) The function will cause the program to exit. D) The function will throw an integer exception which is passed to the calling code.

C

If a function throws an exception, A) it causes a syntax error. B) it must be caught in that function. C) it may be caught in that function. D) it can only be a non-numeric exception.

C

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 A) not throw any exceptions. B) not throw any exceptions that the function in class B might throw. C) have an exception specification that is a subset of the exception specification of the base class B. D) all of the above

C

Which type of exception is thrown if a call to the new operator fails? A) MemoryError B) DivideByZero C) bad_alloc D) ArithmeticError

C

The following catch statement: catch(...) { /* catch block code */ } A) catches only numeric exceptions. B) should be the first catch block if multiple catch statements are present. C) is illegal. D) catches all exceptions.

D

When an unusual situation or error occurs, then the ________ statement is executed. A) error B) try C) exiting D) throw

D

A throw statement can throw A) an exception of any data type. B) an integer exception. C) a float exception. D) a bool exception. E) all of the above

E

Functions may potentially throw at most one exception.

F

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

F

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

F

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

F

None of the STL algorithms modifies the sequence of elements in any possible containers.

F

The Standard Template Library (STL) consists of container classes of various kinds.

F

The braces are not necessary to enclose a try block.

F

The catch block is a function.

F

In the STL, iterators provide the "glue" connecting container classes and generic algorithms.

T

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

T

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

T

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

T

The model for the iterator in the STL was the pointer.

T

The throw statement passes a value to the catch block.

T

If the following function throws an unhandled exception, what happens? void f1( );

The exception will propagate to the calling program or function

If the following function throws an unhandled exception, what happens? void f1( ) throws ( );

The program will exit.

If a function throws an exception and does not catch it, then the function definition and declaration should have ________.

an exception specification or throw list

If a function does not have an exception specification, then the function can throw ________ exceptions.

any

A throw statement passes which type of value to the catch block?

any valid data type

If no exception is thrown, then the ________ is ignored.

catch block

If a throw list has multiple exceptions listed, they are separated by ________.

commas

The following catch block is known as the ________. catch (...) { /* catch block code */ }

default catch block

If a function throw list specifies a base class type, then the function may also throw an exception of the ________ class type.

derived

The catch block is also known as the ________.

exception handler

If some part of your program (or any library functions that are called) throw an exception, then if this exception is not handled in your code, your program will ________.

exit

In C++, generic algorithms are implemented using ___________ templates.

function

Exception handling is used to ________.

handle error situations or exceptional situations

The following catch block catches all ________ exceptions. catch ( string e) { /* catch block code */ }

string

C++ signals an error or unusual situation by ________.

throwing an exception

Can the following function throw any unhandled exceptions? void f1( );

yes


Kaugnay na mga set ng pag-aaral

CH. 1 & 2 - intro to stat / summarizing and graphing

View Set

Physics Semester 2 All Multiple Choice Review

View Set

Chapter 8. Flexible Budgets, Standard Costs, and Variance Analysis

View Set

Chapter 12: Firefighting Concerns of Green Construction (Fire 004)

View Set

Health & Life Insurance - Part 7

View Set

Final Exam- Spinal Cord , Autonomic Dysreflexia

View Set

Government- Civil War Amendments

View Set