Deck 7: Class Templates Array and Vector; Catching Exceptions
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/18
العب
ملء الشاشة (f)
Deck 7: Class Templates Array and Vector; Catching Exceptions
1
Linear search can be used on:
A) Unsorted arrays.
B) Sorted arrays.
C) Integer arrays.
D) Any of the above.
A) Unsorted arrays.
B) Sorted arrays.
C) Integer arrays.
D) Any of the above.
D
2
Using square brackets ([]) to retrieve vector elements __________ perform bounds checking; using member function at to retrieve vector elements __________ perform bounds checking.
A) Does not, does not.
B) Does not, does.
C) Does, does not.
D) Does, does.
A) Does not, does not.
B) Does not, does.
C) Does, does not.
D) Does, does.
B
3
Which of the following is not true of class template vector?
A) The size of a vector can be changed after it is declared.
B) A vector can be assigned to another vector by using the assignment operator.
C) A vector object can be initialized with a copy of another vector by invoking the copy constructor.
D) A vector can store only data of type int.
A) The size of a vector can be changed after it is declared.
B) A vector can be assigned to another vector by using the assignment operator.
C) A vector object can be initialized with a copy of another vector by invoking the copy constructor.
D) A vector can store only data of type int.
D
4
Which of the following tasks cannot be performed using a range-based for loop?
A) Calculating the product of all the values in an array.
B) Displaying all even element values in an array.
C) Incrementing the value stored in each element of the array.
D) Accessing the element's subscript.
A) Calculating the product of all the values in an array.
B) Displaying all even element values in an array.
C) Incrementing the value stored in each element of the array.
D) Accessing the element's subscript.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 18 في هذه المجموعة.
فتح الحزمة
k this deck
5
You can sort an array with the Standard Library's:
A) sort function.
B) sort_array function.
C) array_sort function.
D) None of the above.
A) sort function.
B) sort_array function.
C) array_sort function.
D) None of the above.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 18 في هذه المجموعة.
فتح الحزمة
k this deck
6
A double subscripted array declared as array, 3> values; has how many elements?
A) 15
B) 13
C) 10
D) 8
A) 15
B) 13
C) 10
D) 8
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 18 في هذه المجموعة.
فتح الحزمة
k this deck
7
When using exception handling, place any code that might throw an exception in a __________.
A) catch block
B) try statement.
C) throw block.
D) what statement.
A) catch block
B) try statement.
C) throw block.
D) what statement.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 18 في هذه المجموعة.
فتح الحزمة
k this deck
8
In a typical nested for loop (not a range-based for loop) used to process a two-dimensional array, following the end of each execution of the inner for loop:
A) The outer for loop initializes its counter variable.
B) The outer for loop increments its counter variable.
C) The inner for loop initializes its counter variable.
D) The inner for loop increments its counter variable.
A) The outer for loop initializes its counter variable.
B) The outer for loop increments its counter variable.
C) The inner for loop initializes its counter variable.
D) The inner for loop increments its counter variable.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 18 في هذه المجموعة.
فتح الحزمة
k this deck
9
Constant variables:
A) Can be assigned values in executable statements.
B) Do not have to be initialized when they are declared.
C) Can be used to specify array sizes, thereby making programs more scalable.
D) Can be used to specify array sizes, but this makes programs harder to understand.
A) Can be assigned values in executable statements.
B) Do not have to be initialized when they are declared.
C) Can be used to specify array sizes, thereby making programs more scalable.
D) Can be used to specify array sizes, but this makes programs harder to understand.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 18 في هذه المجموعة.
فتح الحزمة
k this deck
10
Assume that the array named items contains the integer values 0, 2, 4, 6 and 8. Which of the following set of statements uses the range-based for loop to display each value in items?
A) for (int i = 0; i}
B) for (int item : items) { cout <}
C) for (int item : items) { cout <- }
D) for (int item : items.size()){ cout <- }
A) for (int i = 0; i
B) for (int item : items) { cout <
C) for (int item : items) { cout <
D) for (int item : items.size()){ cout <
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 18 في هذه المجموعة.
فتح الحزمة
k this deck
11
Which of the following is not a correct way to initialize the array named n?
A) array n{0, 7, 0, 3, 8};
B) array n{0, 7, 0, 3, 8, 2};
C) array n{7};
D) array n{9, 1, 9};
A) array
B) array
C) array
D) array
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 18 في هذه المجموعة.
فتح الحزمة
k this deck
12
An array is not:
A) A consecutive group of memory locations.
B) Subscripted by integers.
C) Made up of different data types.
D) None of the above.
A) A consecutive group of memory locations.
B) Subscripted by integers.
C) Made up of different data types.
D) None of the above.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 18 في هذه المجموعة.
فتح الحزمة
k this deck
13
Which statement would be used to declare a 10-element integer array c?
A) array c<12>;
B) array c;
C) array<12> c;
D) array c;
A) array c<12>;
B) array c
C) array<12> c;
D) array
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 18 في هذه المجموعة.
فتح الحزمة
k this deck
14
In order to calculate the __________ of an array of values, the array values must first be summed.
A) Average.
B) Minimum.
C) Maximum.
D) Distribution.
A) Average.
B) Minimum.
C) Maximum.
D) Distribution.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 18 في هذه المجموعة.
فتح الحزمة
k this deck
15
Which statement about exception handling is false?
A) Call the exception object's what member function to get the error message that's stored in the exception object.
B) Bounds checking is performed at execution time with vector member function at, and if a subscript is within the bounds of the array, the member function throws an out_of_bounds exception.
C) The catch block contains the code that handles an exception if one occurs.
D) None of the above statements in false.
A) Call the exception object's what member function to get the error message that's stored in the exception object.
B) Bounds checking is performed at execution time with vector member function at, and if a subscript is within the bounds of the array, the member function throws an out_of_bounds exception.
C) The catch block contains the code that handles an exception if one occurs.
D) None of the above statements in false.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 18 في هذه المجموعة.
فتح الحزمة
k this deck
16
Which of the following does not declare a 2-by-2 array and set all four of its elements to 0?
A) array, 2> b; b[0][0] = b[0][1] = b[1][0] = b[1][1] = 0;
B) array, 2> b = {0};
C) array, 2> b; for (auto const &row : b) {
For (auto &element : row) {
Element = 0;
}
}
D) All of the above initialize all four of the array elements to 0.
A) array
B) array
C) array
For (auto &element : row) {
Element = 0;
}
}
D) All of the above initialize all four of the array elements to 0.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 18 في هذه المجموعة.
فتح الحزمة
k this deck
17
Which of the following is false?
A) The last element of an array has position number one less than the array size.
B) The position number contained within square brackets is called a subscript.
C) A subscript cannot be an expression.
D) All of the above.
A) The last element of an array has position number one less than the array size.
B) The position number contained within square brackets is called a subscript.
C) A subscript cannot be an expression.
D) All of the above.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 18 في هذه المجموعة.
فتح الحزمة
k this deck
18
Referencing elements outside the array bounds with the [] operator:
A) Can result in changes to the value of an unrelated variable.
B) Is impossible because C++ checks to make sure it does not happen.
C) Is a syntax error.
D) Enlarges the size of the array.
A) Can result in changes to the value of an unrelated variable.
B) Is impossible because C++ checks to make sure it does not happen.
C) Is a syntax error.
D) Enlarges the size of the array.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 18 في هذه المجموعة.
فتح الحزمة
k this deck