Filters
Question type

Study Flashcards

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.

E) C) and D)
F) B) and D)

Correct Answer

verifed

verified

Which of the following is not a correct way to initialize the array named n?


A) array<int, 5> n{0, 7, 0, 3, 8};
B) array<int, 5> n{0, 7, 0, 3, 8, 2};
C) array<int, 5> n{7};
D) array<int, 5> n{9, 1, 9};

E) B) and D)
F) B) and C)

Correct Answer

verifed

verified

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.

E) A) and B)
F) None of the above

Correct Answer

verifed

verified

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.

E) A) and B)
F) None of the above

Correct Answer

verifed

verified

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.

E) A) and B)
F) C) and D)

Correct Answer

verifed

verified

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 <items.size() ; ++i) { cout <}
B) for (int item : items) { cout <}
C) for (int item : items) { cout <}
D) for (int item : items.size() ) { cout <}

E) A) and C)
F) A) and B)

Correct Answer

verifed

verified

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.

E) None of the above
F) B) and C)

Correct Answer

verifed

verified

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.

E) A) and B)
F) B) and D)

Correct Answer

verifed

verified

A

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.

E) A) and C)
F) All of the above

Correct Answer

verifed

verified

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.

E) A) and B)
F) None of the above

Correct Answer

verifed

verified

A double subscripted array declared as array<array<int, 5>, 3> values; has how many elements?


A) 15
B) 13
C) 10
D) 8

E) B) and D)
F) A) and B)

Correct Answer

verifed

verified

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.

E) All of the above
F) B) and C)

Correct Answer

verifed

verified

B

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.

E) B) and C)
F) None of the above

Correct Answer

verifed

verified

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.

E) A) and B)
F) None of the above

Correct Answer

verifed

verified

Linear search can be used on:


A) Unsorted arrays.
B) Sorted arrays.
C) Integer arrays.
D) Any of the above.

E) None of the above
F) A) and D)

Correct Answer

verifed

verified

D

Which of the following does not declare a 2-by-2 array and set all four of its elements to 0?


A) array<array<int,2>, 2> b; b[0][0] = b[0][1] = b[1][0] = b[1][1] = 0;
B) array<array<int, 2>, 2> b = {0};
C) array<array<int, 2>, 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.

E) A) and D)
F) A) and C)

Correct Answer

verifed

verified

Which statement would be used to declare a 10-element integer array c?


A) array c<12>;
B) array c<int, 12>;
C) array<12> c;
D) array<int, 12> c;

E) B) and D)
F) B) and C)

Correct Answer

verifed

verified

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.

E) None of the above
F) C) and D)

Correct Answer

verifed

verified

Showing 1 - 18 of 18

Related Exams

Show Answer