Deck 16: Exception Handling

ملء الشاشة (f)
exit full mode
سؤال
If a function throws an exception, it must be caught inside that function.
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
The catch block
catch ...)
is known as the ______________.
سؤال
Functions may potentially throw at most one exception.
سؤال
The catch block is a function.
سؤال
The catch block is the group of statements that handle an exception.
سؤال
Exception handling is used to _____________.
سؤال
The braces are not necessary on a try block.
سؤال
C++ signals an error or unusual situation by __________.
سؤال
A throw statement passes which type of value to the catch block?
سؤال
The throw statement passes a value to the catch block.
سؤال
Functions that might throw an exception must have a throw list.
سؤال
If a function does not have an exception specification, then the function can thaw _______ exceptions.
سؤال
The following function does not throw any unhandled exceptions
void f1 ) throw );
سؤال
The catch block is also known as the ___________.
سؤال
The following catch block catches all __________ exceptions.
catch string e)
{
}
سؤال
If no exception is thrown, then the _________ is ignored.
سؤال
If a function throws an exception and does not catch it, then the function definition and declaration should have _______.
سؤال
In a try block, the throw statement is always executed.
سؤال
It is legal to have a catch block with no parameter.
سؤال
If a throw list has multiple exceptions listed, they are separated by _________.
سؤال
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
سؤال
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
سؤال
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
سؤال
If the following function throws an unhandled exception, what happens?
void f1);
سؤال
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
سؤال
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
سؤال
When an unusual situation or error occurs, then the ________ statement is executed.

A) try
B) throw
C) error
D) exiting
سؤال
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
سؤال
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
سؤال
Can the following function throw any unhandled exceptions?
void f1 );
سؤال
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.
سؤال
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
سؤال
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
سؤال
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
سؤال
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 _____.
سؤال
If a function throw list specifies a base class type, then the function may also throw an exception of the ________ class type.
سؤال
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);
سؤال
The throw statement is enclosed in

A) a catch block
B) a throw block
C) a try block
D) quotes
سؤال
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
سؤال
If the following function throws an unhandled exception, what happens?
void f1) throws );
سؤال
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
سؤال
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
سؤال
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
سؤال
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
سؤال
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
سؤال
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
سؤال
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 Deck
1/47
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 16: Exception Handling
1
If a function throws an exception, it must be caught inside that function.
False
2
The catch block
catch ...)
is known as the ______________.
default catch block
3
Functions may potentially throw at most one exception.
False
4
The catch block is a function.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 47 في هذه المجموعة.
فتح الحزمة
k this deck
5
The catch block is the group of statements that handle an exception.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 47 في هذه المجموعة.
فتح الحزمة
k this deck
6
Exception handling is used to _____________.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 47 في هذه المجموعة.
فتح الحزمة
k this deck
7
The braces are not necessary on a try block.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 47 في هذه المجموعة.
فتح الحزمة
k this deck
8
C++ signals an error or unusual situation by __________.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 47 في هذه المجموعة.
فتح الحزمة
k this deck
9
A throw statement passes which type of value to the catch block?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 47 في هذه المجموعة.
فتح الحزمة
k this deck
10
The throw statement passes a value to the catch block.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 47 في هذه المجموعة.
فتح الحزمة
k this deck
11
Functions that might throw an exception must have a throw list.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 47 في هذه المجموعة.
فتح الحزمة
k this deck
12
If a function does not have an exception specification, then the function can thaw _______ exceptions.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 47 في هذه المجموعة.
فتح الحزمة
k this deck
13
The following function does not throw any unhandled exceptions
void f1 ) throw );
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 47 في هذه المجموعة.
فتح الحزمة
k this deck
14
The catch block is also known as the ___________.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 47 في هذه المجموعة.
فتح الحزمة
k this deck
15
The following catch block catches all __________ exceptions.
catch string e)
{
}
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 47 في هذه المجموعة.
فتح الحزمة
k this deck
16
If no exception is thrown, then the _________ is ignored.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 47 في هذه المجموعة.
فتح الحزمة
k this deck
17
If a function throws an exception and does not catch it, then the function definition and declaration should have _______.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 47 في هذه المجموعة.
فتح الحزمة
k this deck
18
In a try block, the throw statement is always executed.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 47 في هذه المجموعة.
فتح الحزمة
k this deck
19
It is legal to have a catch block with no parameter.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 47 في هذه المجموعة.
فتح الحزمة
k this deck
20
If a throw list has multiple exceptions listed, they are separated by _________.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 47 في هذه المجموعة.
فتح الحزمة
k this deck
21
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 47 في هذه المجموعة.
فتح الحزمة
k this deck
22
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 47 في هذه المجموعة.
فتح الحزمة
k this deck
23
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 47 في هذه المجموعة.
فتح الحزمة
k this deck
24
If the following function throws an unhandled exception, what happens?
void f1);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 47 في هذه المجموعة.
فتح الحزمة
k this deck
25
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 47 في هذه المجموعة.
فتح الحزمة
k this deck
26
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 47 في هذه المجموعة.
فتح الحزمة
k this deck
27
When an unusual situation or error occurs, then the ________ statement is executed.

A) try
B) throw
C) error
D) exiting
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 47 في هذه المجموعة.
فتح الحزمة
k this deck
28
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 47 في هذه المجموعة.
فتح الحزمة
k this deck
29
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 47 في هذه المجموعة.
فتح الحزمة
k this deck
30
Can the following function throw any unhandled exceptions?
void f1 );
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 47 في هذه المجموعة.
فتح الحزمة
k this deck
31
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 47 في هذه المجموعة.
فتح الحزمة
k this deck
32
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 47 في هذه المجموعة.
فتح الحزمة
k this deck
33
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 47 في هذه المجموعة.
فتح الحزمة
k this deck
34
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 47 في هذه المجموعة.
فتح الحزمة
k this deck
35
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 _____.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 47 في هذه المجموعة.
فتح الحزمة
k this deck
36
If a function throw list specifies a base class type, then the function may also throw an exception of the ________ class type.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 47 في هذه المجموعة.
فتح الحزمة
k this deck
37
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);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 47 في هذه المجموعة.
فتح الحزمة
k this deck
38
The throw statement is enclosed in

A) a catch block
B) a throw block
C) a try block
D) quotes
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 47 في هذه المجموعة.
فتح الحزمة
k this deck
39
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 47 في هذه المجموعة.
فتح الحزمة
k this deck
40
If the following function throws an unhandled exception, what happens?
void f1) throws );
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 47 في هذه المجموعة.
فتح الحزمة
k this deck
41
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 47 في هذه المجموعة.
فتح الحزمة
k this deck
42
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 47 في هذه المجموعة.
فتح الحزمة
k this deck
43
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 47 في هذه المجموعة.
فتح الحزمة
k this deck
44
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 47 في هذه المجموعة.
فتح الحزمة
k this deck
45
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 47 في هذه المجموعة.
فتح الحزمة
k this deck
46
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 47 في هذه المجموعة.
فتح الحزمة
k this deck
47
Which type of exception is thrown if a call to the new operator fails?

A) ArithmeticError
B) DivideByZero
C) bad_alloc
D) MemoryError
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 47 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 47 في هذه المجموعة.