Deck 16: Exception Handling

Full screen (f)
exit full mode
Question
The braces are not necessary on a try block.
Use Space or
up arrow
down arrow
to flip the card.
Question
Exception handling is used to _____________.
Question
The catch block
catch ...)
is known as the ______________.
Question
A throw statement passes which type of value to the catch block?
Question
In a try block,the throw statement is always executed.
Question
If a throw list has multiple exceptions listed,they are separated by _________.
Question
The throw statement passes a value to the catch block.
Question
The following catch block catches all __________ exceptions.
catch string e)
{
}
Question
If a function throws an exception,it must be caught inside that function.
Question
C++ signals an error or unusual situation by __________.
Question
It is legal to have a catch block with no parameter.
Question
The catch block is a function.
Question
The catch block is the group of statements that handle an exception.
Question
If no exception is thrown,then the _________ is ignored.
Question
Functions may potentially throw at most one exception.
Question
If a function does not have an exception specification,then the function can thaw _______ exceptions.
Question
The catch block is also known as the ___________.
Question
The following function does not throw any unhandled exceptions
void f1 )throw );
Question
If a function throws an exception and does not catch it,then the function definition and declaration should have _______.
Question
Functions that might throw an exception must have a throw list.
Question
The parameter in the catch statement

A)identifies what type of exceptions are caught
B)identifies the different number of exceptions that can be caught
C)makes the catch block a function
D)must always be an e
Question
If the following function throws an unhandled exception,what happens?
void f1)throws );
Question
If the following function will throw a string exception,then
Void myFunction );

A)the function definition and declaration should have a throw list
B)the function definition,but not the declaration should have a throw list
C)the function should have an empty throw list.
D)all of the above
Question
The throw statement is enclosed in

A)a catch block
B)a throw block
C)a try block
D)quotes
Question
A catch block that expects an integer argument will catch

A)all exceptions
B)all integer exceptions
C)any exception value that can be coerced into an integer
D)none of the above
Question
If the following function throws an unhandled exception,what happens?
void f1);
Question
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)not catch the exception in the function
B)throw an integer exception
C)never throw an exception in this function
D)none of the above
Question
If a function throws an exception,

A)it must be caught in that function.
B)it may be caught in that function
C)it causes a syntax error
D)it can only be a non-numeric exception.
Question
The following class definition
Class MyError
{};

A)has no member functions or member data
B)has only a default constructor
C)is illegal
D)A and B
Question
When a throw statement is executed,

A)execution of the try block stops
B)execution of the throw block stops
C)the program always exits
D)execution of the catch block stops
Question
The following catch statement
Catch...)

A)is illegal
B)catches only numeric exceptions
C)catches all exceptions
D)should be the first catch block if multiple catch statements are present
Question
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 _____.
Question
The block of code that handles an exception is called

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

A)the catch block
B)the try block
C)a function
D)an error block
Question
Can the following function throw any unhandled exceptions?
void f1 );
Question
Which of the following function declaration correctly specifies that two types of exceptions are thrown?

A)void f1exception a,exception b);
B)void f1 )exception a;b);
C)void f1 )throw a,throw b;
D)void f1 )thaw a,b);
Question
When an unusual situation or error occurs,then the ________ statement is executed.

A)try
B)throw
C)error
D)exiting
Question
Which of the following is not a valid reason for using exception handling?

A)throw and catch can be used like gotos
B)the procedure for handling an error depends on the situation
C)need to handle built in exceptions
D)none of the above
Question
Given the following function definition,what happens if the function throws the exception?
Void f1 )throw double)
{
If //some code here)
Throw 12;
}

A)the 12 will be converted to 12.0
B)the function will throw an integer exception which is passed to the calling code.
C)the function will cause the program to exit
D)this code has a syntax error
Question
If a function throw list specifies a base class type,then the function may also throw an exception of the ________ class type.
Question
Which type of exception is thrown if a call to the new operator fails?

A)ArithmeticError
B)DivideByZero
C)bad_alloc
D)MemoryError
Question
Which of the following would be a good reason for using inherited exception classes?

A)a base class exception can be passed to an exception parameter of the derived class
B)a derived class exception can be passed to an exception parameter of the base class
C)a base class exception parameter can be passed any type of exception
D)all of the above
Question
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)have an exception specification that is a subset of the exception specification of the base class B
C)not throw any exceptions that the function in class B might throw
D)all of the above
Question
You should use exception handling

A)in all your programs
B)only when you can not handle the exception with simpler control structures
C)only when you use classes
D)in every function
Question
If a function will possibly throw an unhandled exception,the try block should

A)be in the function definition
B)encompass the function call
C)be in the catch block
D)not be used
Question
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
Question
Which of the following code fragments are illegal?

A)try {
Try
{
//other code here
}
Catchint e)
{
//code here
}
}
Catchfloat e)
{
//code here
}
B)try {
//code here
}
Catchint e)
{
//code here
Try
{
//code here
}
Catchstring e)
{
}
}
C)All of the above
D)None of the above
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/47
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 16: Exception Handling
1
The braces are not necessary on a try block.
False
2
Exception handling is used to _____________.
handle error situations or exceptional situations.
3
The catch block
catch ...)
is known as the ______________.
default catch block
4
A throw statement passes which type of value to the catch block?
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
5
In a try block,the throw statement is always executed.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
6
If a throw list has multiple exceptions listed,they are separated by _________.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
7
The throw statement passes a value to the catch block.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
8
The following catch block catches all __________ exceptions.
catch string e)
{
}
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
9
If a function throws an exception,it must be caught inside that function.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
10
C++ signals an error or unusual situation by __________.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
11
It is legal to have a catch block with no parameter.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
12
The catch block is a function.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
13
The catch block is the group of statements that handle an exception.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
14
If no exception is thrown,then the _________ is ignored.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
15
Functions may potentially throw at most one exception.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
16
If a function does not have an exception specification,then the function can thaw _______ exceptions.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
17
The catch block is also known as the ___________.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
18
The following function does not throw any unhandled exceptions
void f1 )throw );
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
19
If a function throws an exception and does not catch it,then the function definition and declaration should have _______.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
20
Functions that might throw an exception must have a throw list.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
21
The parameter in the catch statement

A)identifies what type of exceptions are caught
B)identifies the different number of exceptions that can be caught
C)makes the catch block a function
D)must always be an e
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
22
If the following function throws an unhandled exception,what happens?
void f1)throws );
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
23
If the following function will throw a string exception,then
Void myFunction );

A)the function definition and declaration should have a throw list
B)the function definition,but not the declaration should have a throw list
C)the function should have an empty throw list.
D)all of the above
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
24
The throw statement is enclosed in

A)a catch block
B)a throw block
C)a try block
D)quotes
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
25
A catch block that expects an integer argument will catch

A)all exceptions
B)all integer exceptions
C)any exception value that can be coerced into an integer
D)none of the above
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
26
If the following function throws an unhandled exception,what happens?
void f1);
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
27
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)not catch the exception in the function
B)throw an integer exception
C)never throw an exception in this function
D)none of the above
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
28
If a function throws an exception,

A)it must be caught in that function.
B)it may be caught in that function
C)it causes a syntax error
D)it can only be a non-numeric exception.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
29
The following class definition
Class MyError
{};

A)has no member functions or member data
B)has only a default constructor
C)is illegal
D)A and B
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
30
When a throw statement is executed,

A)execution of the try block stops
B)execution of the throw block stops
C)the program always exits
D)execution of the catch block stops
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
31
The following catch statement
Catch...)

A)is illegal
B)catches only numeric exceptions
C)catches all exceptions
D)should be the first catch block if multiple catch statements are present
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
32
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 _____.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
33
The block of code that handles an exception is called

A)the catch block
B)the try block
C)a function
D)an error block
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
34
The block of code that checks if an unusual situation or error occurs is called

A)the catch block
B)the try block
C)a function
D)an error block
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
35
Can the following function throw any unhandled exceptions?
void f1 );
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
36
Which of the following function declaration correctly specifies that two types of exceptions are thrown?

A)void f1exception a,exception b);
B)void f1 )exception a;b);
C)void f1 )throw a,throw b;
D)void f1 )thaw a,b);
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
37
When an unusual situation or error occurs,then the ________ statement is executed.

A)try
B)throw
C)error
D)exiting
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
38
Which of the following is not a valid reason for using exception handling?

A)throw and catch can be used like gotos
B)the procedure for handling an error depends on the situation
C)need to handle built in exceptions
D)none of the above
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
39
Given the following function definition,what happens if the function throws the exception?
Void f1 )throw double)
{
If //some code here)
Throw 12;
}

A)the 12 will be converted to 12.0
B)the function will throw an integer exception which is passed to the calling code.
C)the function will cause the program to exit
D)this code has a syntax error
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
40
If a function throw list specifies a base class type,then the function may also throw an exception of the ________ class type.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
41
Which type of exception is thrown if a call to the new operator fails?

A)ArithmeticError
B)DivideByZero
C)bad_alloc
D)MemoryError
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
42
Which of the following would be a good reason for using inherited exception classes?

A)a base class exception can be passed to an exception parameter of the derived class
B)a derived class exception can be passed to an exception parameter of the base class
C)a base class exception parameter can be passed any type of exception
D)all of the above
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
43
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)have an exception specification that is a subset of the exception specification of the base class B
C)not throw any exceptions that the function in class B might throw
D)all of the above
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
44
You should use exception handling

A)in all your programs
B)only when you can not handle the exception with simpler control structures
C)only when you use classes
D)in every function
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
45
If a function will possibly throw an unhandled exception,the try block should

A)be in the function definition
B)encompass the function call
C)be in the catch block
D)not be used
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
46
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
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
47
Which of the following code fragments are illegal?

A)try {
Try
{
//other code here
}
Catchint e)
{
//code here
}
}
Catchfloat e)
{
//code here
}
B)try {
//code here
}
Catchint e)
{
//code here
Try
{
//code here
}
Catchstring e)
{
}
}
C)All of the above
D)None of the above
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 47 flashcards in this deck.