Deck 14: Exception Handling

ملء الشاشة (f)
exit full mode
سؤال
A catch block specifies the type of exception it can catch and immediately terminates the program.
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
The try block is followed by one or more ____ blocks.

A) throw
B) finally
C) do
D) catch
سؤال
Which of the following blocks is designed to catch any type of exception?

A) catch(){ }
B) catch(...){ }
C) catch(*){ }
D) catch(exception){ }
سؤال
The code to handle exceptions depends on the type of application you develop.
سؤال
Which of the following statements throws a valid exception in C++?

A) throw.function();
B) throw 2;
C) throws str;
D) 4 throw;
سؤال
The statements that may generate an exception are placed in a ____ block.

A) throw
B) finally
C) try
D) catch
سؤال
When division by zero occurs and the problem is not addressed,the program crashes with an error message that is ____ dependent.

A) code
B) computer
C) platform
D) IDE
سؤال
A catch block can have,at most,____ catch block parameter(s).

A) zero
B) one
C) two
D) three
سؤال
To use the assert function in your program,you should include the statement ____.

A) #include
B) #include
C) #include
D) #include
سؤال
An object that is being thrown cannot be an anonymous object.
سؤال
A(n)____ is an occurrence of an undesirable situation that can be detected during program execution.

A) error
B) exception
C) mistake
D) bug
سؤال
The heading of a try block can contain ellipses in place of a parameter.
سؤال
C++ provides all the exception classes you will ever need.
سؤال
The function ____ can check whether an expression meets the required conditions; if the conditions are not met,it terminates the program.

A) check
B) look
C) assert
D) what
سؤال
The order of the catch blocks does not affect the program.
سؤال
If the catch block with an ellipses (in the heading)is needed,then it should be the first catch block in a sequence of try/catch blocks.
سؤال
If no exception is thrown in a try block,all catch blocks associated with that try block are ignored.
سؤال
Which of the following is a valid C++ statement?

A) assert(0 = divisor);
B) assert(divisor != 0);
C) assert(divisor 0);
D) assert(divisor is 0);
سؤال
One of the typical ways of dealing with exceptions is to use an if statement.
سؤال
In C++,any class can be considered an exception class.
سؤال
The class ____ is designed to deal with illegal arguments used in a function call.

A) invalid_function
B) invalid_parameter
C) invalid_call
D) invalid_argument
سؤال
A(n)____________________ block specifies the type of exception it can catch and contains an exception handler.
سؤال
The general syntax to rethrow an exception caught by a catch block is: ____ (in this case,the same exception is rethrown).

A) rethrow;
B) throw;
C) rethrow exception;
D) throw exception;
سؤال
When an exception is thrown in a function,the function-call stack is ____ so that the exception can be caught in the next try/catch block.

A) destroyed
B) allocated
C) unbound
D) unwound
سؤال
In C++,throw is a(n)____________________ word.
سؤال
The class ____ is the base of the classes designed to handle exceptions.

A) class
B) exception
C) logic_error
D) runtime_error
سؤال
To deal with logical errors in a program,such as a string subscript out of range or an invalid argument to a function call,several classes are derived from the class ____.

A) logic_error
B) logic_exception
C) runtime_error
D) exception
سؤال
In a sequence of try/catch blocks,the last catch block of that sequence should be ____.

A) catch(...){ }
B) catch(int x){ }
C) catch(str){ }
D) catch(exception){}
سؤال
Which of the following options should you choose when an exception occurs in the program that analyzes an airline's ticketing transactions?

A) Terminate the program.
B) Include code in the program to recover from the exception.
C) Log the error and continue.
D) Include code in the header file.
سؤال
Throwing an exception is typically done using the ____________________ statement.
سؤال
The class ____ is designed to deal with errors that can be detected only during program execution.

A) error
B) exception
C) runtime_error
D) logic_error
سؤال
The logic_error and runtime_error classes are defined in the header file ____.

A) stdex
B) stdlib
C) stdexcept
D) exception
سؤال
The ____________________ of the catch block parameter specifies the type of exception that the catch block can catch.
سؤال
Which of the following statements creates a new exception class?

A) class myClass {};
B) class myClass {} implements exception;
C) class myExceptionClass {} extends exception;
D) class myExceptionClass {} throws exception;
سؤال
Suppose you have written a program that inputs data from a file.If the input file does not exist when the program executes,then which option should you choose for handling the issue?

A) Terminate the program.
B) Include code in the program to recover from the exception.
C) Log the error and continue.
D) Include code in the header file.
سؤال
If you want to include members in your exception class,you typically include the function ____.

A) that
B) this
C) log
D) what
سؤال
Which of the following classes is derived from the class runtime_error?

A) bad_alloc
B) out_of_range
C) overflow_error
D) length_error
سؤال
When an exception is thrown,if the program does not handle the exception,then the function ____ is called to terminate the program.

A) log
B) what
C) terminate
D) close
سؤال
The function ____ of the class exception returns a string containing an appropriate message.

A) where
B) what
C) when
D) log
سؤال
If,during program execution,division by ____________________ occurs with integer values and is not addressed by the program,the program might terminate with an error message or might simply hang.
سؤال
When an exception occurs in a try block,control immediately passes to one of the ____________________ blocks.
سؤال
All derived classes of the class exception override the function ____________________ to issue their own error messages.
سؤال
If the operator new cannot allocate memory space,this operator throws a(n)____________________ exception.
سؤال
When an exception occurs in a program,the programmer usually has three choices: ____________________ the program,include code in the program to recover from the exception,or log the error and continue.
سؤال
The class ____________________ contains the function what.
سؤال
If a length greater than the maximum allowed for a string object is used,the class ____________________ deals with the error that occurs.
سؤال
The string concatenation operator is ____________________.
سؤال
If the operator new cannot allocate memory space,this operator throws a(n)____________________ exception.
سؤال
The class ____________________ deals with the string subscript out of range error.
سؤال
When an exception is thrown in a function,the function can do the following: ____________________; partially process the exception and throw the same exception or a new exception; or throw a new exception.
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/50
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 14: Exception Handling
1
A catch block specifies the type of exception it can catch and immediately terminates the program.
False
2
The try block is followed by one or more ____ blocks.

A) throw
B) finally
C) do
D) catch
D
3
Which of the following blocks is designed to catch any type of exception?

A) catch(){ }
B) catch(...){ }
C) catch(*){ }
D) catch(exception){ }
B
4
The code to handle exceptions depends on the type of application you develop.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
5
Which of the following statements throws a valid exception in C++?

A) throw.function();
B) throw 2;
C) throws str;
D) 4 throw;
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
6
The statements that may generate an exception are placed in a ____ block.

A) throw
B) finally
C) try
D) catch
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
7
When division by zero occurs and the problem is not addressed,the program crashes with an error message that is ____ dependent.

A) code
B) computer
C) platform
D) IDE
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
8
A catch block can have,at most,____ catch block parameter(s).

A) zero
B) one
C) two
D) three
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
9
To use the assert function in your program,you should include the statement ____.

A) #include
B) #include
C) #include
D) #include
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
10
An object that is being thrown cannot be an anonymous object.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
11
A(n)____ is an occurrence of an undesirable situation that can be detected during program execution.

A) error
B) exception
C) mistake
D) bug
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
12
The heading of a try block can contain ellipses in place of a parameter.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
13
C++ provides all the exception classes you will ever need.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
14
The function ____ can check whether an expression meets the required conditions; if the conditions are not met,it terminates the program.

A) check
B) look
C) assert
D) what
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
15
The order of the catch blocks does not affect the program.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
16
If the catch block with an ellipses (in the heading)is needed,then it should be the first catch block in a sequence of try/catch blocks.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
17
If no exception is thrown in a try block,all catch blocks associated with that try block are ignored.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
18
Which of the following is a valid C++ statement?

A) assert(0 = divisor);
B) assert(divisor != 0);
C) assert(divisor 0);
D) assert(divisor is 0);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
19
One of the typical ways of dealing with exceptions is to use an if statement.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
20
In C++,any class can be considered an exception class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
21
The class ____ is designed to deal with illegal arguments used in a function call.

A) invalid_function
B) invalid_parameter
C) invalid_call
D) invalid_argument
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
22
A(n)____________________ block specifies the type of exception it can catch and contains an exception handler.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
23
The general syntax to rethrow an exception caught by a catch block is: ____ (in this case,the same exception is rethrown).

A) rethrow;
B) throw;
C) rethrow exception;
D) throw exception;
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
24
When an exception is thrown in a function,the function-call stack is ____ so that the exception can be caught in the next try/catch block.

A) destroyed
B) allocated
C) unbound
D) unwound
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
25
In C++,throw is a(n)____________________ word.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
26
The class ____ is the base of the classes designed to handle exceptions.

A) class
B) exception
C) logic_error
D) runtime_error
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
27
To deal with logical errors in a program,such as a string subscript out of range or an invalid argument to a function call,several classes are derived from the class ____.

A) logic_error
B) logic_exception
C) runtime_error
D) exception
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
28
In a sequence of try/catch blocks,the last catch block of that sequence should be ____.

A) catch(...){ }
B) catch(int x){ }
C) catch(str){ }
D) catch(exception){}
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
29
Which of the following options should you choose when an exception occurs in the program that analyzes an airline's ticketing transactions?

A) Terminate the program.
B) Include code in the program to recover from the exception.
C) Log the error and continue.
D) Include code in the header file.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
30
Throwing an exception is typically done using the ____________________ statement.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
31
The class ____ is designed to deal with errors that can be detected only during program execution.

A) error
B) exception
C) runtime_error
D) logic_error
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
32
The logic_error and runtime_error classes are defined in the header file ____.

A) stdex
B) stdlib
C) stdexcept
D) exception
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
33
The ____________________ of the catch block parameter specifies the type of exception that the catch block can catch.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
34
Which of the following statements creates a new exception class?

A) class myClass {};
B) class myClass {} implements exception;
C) class myExceptionClass {} extends exception;
D) class myExceptionClass {} throws exception;
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
35
Suppose you have written a program that inputs data from a file.If the input file does not exist when the program executes,then which option should you choose for handling the issue?

A) Terminate the program.
B) Include code in the program to recover from the exception.
C) Log the error and continue.
D) Include code in the header file.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
36
If you want to include members in your exception class,you typically include the function ____.

A) that
B) this
C) log
D) what
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
37
Which of the following classes is derived from the class runtime_error?

A) bad_alloc
B) out_of_range
C) overflow_error
D) length_error
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
38
When an exception is thrown,if the program does not handle the exception,then the function ____ is called to terminate the program.

A) log
B) what
C) terminate
D) close
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
39
The function ____ of the class exception returns a string containing an appropriate message.

A) where
B) what
C) when
D) log
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
40
If,during program execution,division by ____________________ occurs with integer values and is not addressed by the program,the program might terminate with an error message or might simply hang.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
41
When an exception occurs in a try block,control immediately passes to one of the ____________________ blocks.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
42
All derived classes of the class exception override the function ____________________ to issue their own error messages.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
43
If the operator new cannot allocate memory space,this operator throws a(n)____________________ exception.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
44
When an exception occurs in a program,the programmer usually has three choices: ____________________ the program,include code in the program to recover from the exception,or log the error and continue.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
45
The class ____________________ contains the function what.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
46
If a length greater than the maximum allowed for a string object is used,the class ____________________ deals with the error that occurs.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
47
The string concatenation operator is ____________________.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
48
If the operator new cannot allocate memory space,this operator throws a(n)____________________ exception.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
49
The class ____________________ deals with the string subscript out of range error.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
50
When an exception is thrown in a function,the function can do the following: ____________________; partially process the exception and throw the same exception or a new exception; or throw a new exception.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.