Quiz7
7.9 Q1: A double subscripted array element declared as a[ 3 ][ 5 ] has how many elements?
Answer: 15.
7.9 Q2: Given the following declaration, what is the value of b[ 1 ][ 0 ]? int b[ 2 ][ 2 ] = { { 1 }, { 3 , 4 } };
Answer: 3.
7.12 Q2: A message between two objects in a UML sequence diagram is represented by:
Answer: A solid line with a filled arrowhead.
7.2 Q3: Which of the following is not true?
Answer: A subscript cannot be an expression.
7.11 Q1: Which of the following is not true of class template vector?
Answer: A vector can only store data type int.
7.9 Q3: Which of the following does not declare a 2-by-2 array and set all four of its elements to 0?
Answer: All of the above initialize all of their elements to 0.
7.7 Q1: Linear search can be used on:
Answer: Any of the above.
7.6 Q1: In order to calculate the __________ of an array of values, the array values must be summed.
Answer: Average.
7.5 Q1: Unless otherwise specified, entire arrays are passed __________ and individual array elements are passed
Answer: By reference, by value.
7.4 Q2: Constant variables:
Answer: Can be used to specify array sizes, thereby making programs more scalable.
7.4 Q3: Referencing elements outside the array bounds:
Answer: Can result in changes to the value of an unrelated variable.
7.11 Q2: Using square brackets ([]) to retrieve vector elements __________ perform bounds checking; using member function at to retrieve vector elements __________ perform bounds checking.
Answer: Does not, does.
7.4 Q4: Strings represented as character arrays cannot:
Answer: Grow or shrink dynamically.
7.5 Q2: Which of the following is false about a function to which an array is being passed?
Answer: It knows the size of the array that is being passed.
7.7 Q2: Linear search is highly inefficient compared to binary search when dealing with:
Answer: Large, sorted arrays.
7.2 Q1: An array is not:
Answer: Made up of different data types.
7.12 Q1: In a UML communication diagram, the first message passed during the processing of message 1 is called:
Answer: Message 1.1.
7.8 Q1: Which statement about insertion sort is true?
Answer: The algorithm is very simple compared to other sorting procedures.
7.5 Q3: To prevent modification of array values passed to a function:
Answer: The array parameter can be preceded by the const qualifier.
7.8 Q2: At the ith iteration of the insertion sort:
Answer: The first i elements of the array are sorted.
7.12 Q3: An activation, represented by a thin vertical rectangle, on an object's lifeline indicates that:
Answer: The object is executing.
7.10 Q1: In a typical nested for loop structure used to process a two-dimensional array, following the end of the each execution of the inner for loop:
Answer: The outer for loop increments its counter variable.
7.2 Q2: Assuming that int a has a value of 3 and that integer array b has 7 elements, what is the correct way to assign the value of the third element plus 3, to the fifth element of the array:
Answer: b[ a + 1 ] = b[ a - 1 ] + 3;.
7.4 Q5: Which of the following character array declarations does not produce a string?
Answer: char string1[] = { 't', 'e', 's', 't' };.
7.3 Q1: Which statement would be used to declare a 10-element integer array c?
Answer: int c[ 10 ];.
7.4 Q1: Which of the following is not a correct way to initialize an array?
Answer: int n[ 5 ] = { 0, 7, 0, 3, 8, 2 };.