Accounting
Anthropology
Archaeology
Art History
Banking
Biology & Life Science
Business
Business Communication
Business Development
Business Ethics
Business Law
Chemistry
Communication
Computer Science
Counseling
Criminal Law
Curriculum & Instruction
Design
Earth Science
Economic
Education
Engineering
Finance
History & Theory
Humanities
Human Resource
International Business
Investments & Securities
Journalism
Law
Management
Marketing
Medicine
Medicine & Health Science
Nursing
Philosophy
Physic
Psychology
Real Estate
Science
Social Science
Sociology
Special Education
Speech
Visual Arts
Computer Science
Q:
(*max)(num1, num2, num3);:
a. Is the header for function max.
b. Is a call to the function pointed to by max.
c. Is the prototype for function max.
d. Is a declaration of a pointer to a function called max.
Q:
Which of the following is not true of pointers to functions?
a. They contain the starting address of the function code.
b. They are dereferenced in order to call the function.
c. They can be stored in arrays.
d. They can not be assigned to other function pointers.
Q:
A string array is commonly used for:
a. Command-line arguments.
b. Storing an extremely long string.
c. Storing multiple copies of the same string.
d. Displaying floating-point numbers to the screen.
Q:
A string array:
a. Stores an actual string in each of its elements.
b. Can only provide access to strings of a certain length.
c. Is actually an array of pointers.
d. Is always less memory efficient than an equivalent double-subscripted array.
Q:
Q:
Q:
Q:
Assuming that t is an array and tPtr is a pointer to that array, which expression refers to the address of element 3 of the array?
a. *(tPtr + 3)
b. tPtr[3]
c. &t[3]
d. *(t + 3)
Q:
Comparing pointers and performing pointer arithmetic on them is meaningless unless:
a. They point to elements of the same array.
b. You are trying to compare and perform pointer arithmetic on the values to which they point.
c. They point to arrays of equal size.
d. They point to arrays of the same type.
Q:
A pointer can not be assigned to:
a. Another pointer of the same type without using the cast operator.
b. A pointer to void without using the cast operator.
c. A pointer of a type other than its own type and void without using the cast operator.
d. Any other pointer by using the cast operator.
Q:
Given that k is an integer array starting at location 2000, kPtr is a pointer to k and each integer is stored in 4 bytes of memory, what location does kPtr + 3 point to?
a. 2003
b. 2006
c. 2012
d. 2024
Q:
Which of the following can have a pointer as an operand?
a. ++
b. *=
c. %
d . /
Q:
Which of the following gives the number of elements in the array int r[10]?
a. sizeof r
b. sizeof (*r)
c. sizeof r / sizeof (int)
d. sizeof (*r) / sizeof (int)
Q:
sizeof:
a. Is a binary operator.
b. Returns the total number of elements in an array.
c. Usually returns a double.
d. Returns the total number of bytes in a variable.
Q:
What method should be used to pass an array to a function that does not modify the array and only looks at it using array subscript notation:
a. A nonconstant pointer to nonconstant data.
b. A nonconstant pointer to constant data.
c. A constant pointer to nonconstant data.
d. A constant pointer to constant data.
Q:
Which of the following best describes the array name n in the declaration int n[10];?
a. n is a nonconstant pointer to nonconstant data.
b. n is a nonconstant pointer to constant data.
c. n is a constant pointer to nonconstant data.
d. n is a constant pointer to constant data.
Q:
A function that prints a string by using pointer arithmetic such as ++ptr to output each character should have a parameter that is:
a. A nonconstant pointer to nonconstant data.
b. A nonconstant pointer to constant data.
c. A constant pointer to nonconstant data.
d. A constant pointer to constant data.
Q:
A function that modifies an array by using pointer arithmetic such as ++ptr to process every value of the array should have a parameter that is:
a. A nonconstant pointer to nonconstant data.
b. A nonconstant pointer to constant data.
c. A constant pointer to nonconstant data.
d. A constant pointer to constant data.
Q:
Given a built-in array of ints named values, which of the following statements would sort the array?
a. sort(values.begin(), values.end());
b. sort(values.array_begin(), values.array_end());
c. sort(begin(values), end(values));
d. sort(array_begin(values), array_end(values));
Q:
Which of the following is false about a function to which a built-in array is being passed?
a. It always knows the size of the built-in array that is being passed.
b. It is being passed the address of the first element in the built-in array.
c. It is able to modify the values stored in the built-in array.
d. The built-in array's name is used as an argument in the function call.
Q:
To prevent modification of a built-in array's values when you pass the built-in array to a function:
a. The built-in array must be declared static in the function.
b. The built-in array parameter can be preceded by the const qualifier.
c. A copy of the built-in array must be made inside the function.
d. The built-in array must be passed by reference.
Q:
Which statement would be used to declare a 10-element integer array c?
a. array c = int[10];
b. c = int[10];
c. int array c[10];
d. int c[10];
Q:
Which of the following is not a correct way to initialize a built-in array?
a. int n[5]{0, 7, 0, 3, 8, 2};
b. int n[]{0, 7, 0, 3, 8, 2};
c. int n[5]{7};
d. int n[5]{9, 1, 9};
Q:
When a compiler encounters a function parameter for a single-subscripted array of the form int a[], it converts the parameter to:
a. int a
b. int &a
c. int *a
d. No conversion is necessary.
Q:
Which of the following is not a valid way to pass arguments to a function in C++?
a. By reference with reference arguments.
b. By value.
c. By reference with pointer arguments.
d. By value with pointer arguments.
Q:
Three of the following expressions have the same value. Which of the following expressions has a value different from the others'?
a. *&ptr
b. &*ptr
c. *ptr
d. ptr
Q:
All of the following can cause a fatal execution-time error except:
a. Dereferencing a pointer that has not been assigned to point to a specific address.
b. Dereferencing a pointer that has not been initialized properly.
c. Dereferencing a null pointer.
d. Dereferencing a variable that is not a pointer.
Q:
The & operator can be applied to:
a. constants.
b. string literals.
c. lvalues.
d. rvalues.
Q:
[C++11]: Which of the following statements about pointer initialization and values is false?a. Prior C++11, the value specified for a null pointer was 0 or NULL.b. When 0 is assigned to a pointer, it's converted to a pointer of the appropriate type.c. The value 0 is the only integer value that can be assigned directly to a pointer variable without first casting the integer to a pointer type.d. In the new standard, you should use the constant null_ptr to initialize a pointer instead of 0 or NULL.
Q:
What does the following statement declare?
int *countPtr, count;
a. Two int variables.
b. One pointer to an int and one int variable.
c. Two pointers to ints.
d. The declaration is invalid.
Q:
Pointers may be assigned which of the following values?
a. Any integer values.
b. An address.
c. nullptr.
d. Both (b) and (c).
Q:
Pointers cannot be used to:
a. Contain memory addresses.
b. Reference values directly.
c. Pass an argument by reference.
d. Manipulate dynamic data structures.
Q:
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.
Q:
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.
Q:
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.
Q:
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.
Q:
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.
Q:
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.
Q:
A double subscripted array declared as array<array<int, 5>, 3> values; has how many elements?
a. 15
b. 13
c. 10
d. 8
Q:
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.
Q:
Linear search can be used on:
a. Unsorted arrays.
b. Sorted arrays.
c. Integer arrays.
d. Any of the above.
Q:
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.
Q:
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.
Q:
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 <<items[i] <<endl;
}
b. for (int item : items) {
cout <<items[item] <<endl;
}
c. for (int item : items) {
cout <<item <<endl;
}
d. for (int item : items.size()){
cout <<item <<endl;
}
Q:
Referencing elements outside the arraybounds 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.
Q:
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.
Q:
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};
Q:
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;
Q:
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.
Q:
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.
Q:
All of the following are reasons to use recursion except:
a. An iterative solution is not apparent.
b. The resulting program is easier to debug.
c. It more naturally mirrors the problem.
d. It maximizes execution performance.
Q:
Recursion is to the base case as iteration is to what:
a. The counter.
b. A repetition structure.
c. Failure of the loop continuation test.
d. A selection structure.
Q:
For which of the following operators does C++ not specify the order of evaluation of its operands?
a. +.
b. &&.
c. ,.
d. ?:.
Q:
Assuming the following pseudocode for the Fibonacci series, what is the value of the 5th Fibonacci number (fibonacci (5))?fibonacci(0) = 0fibonacci(1) = 1fibonacci(n) = fibonacci(n - 1) + fibonacci(n - 2)a. 1.b. 3.c. 5.d. 7.
Q:
C++11's unsigned long long int type (which can be abbreviated as unsigned long long) enables you to store values in at least ________, which can hold numbers as large as 18,446,744,073,709,551,615.
a. 2 bytes (16 bits)
b. 4 bytes (32 bits)
c. 8 bytes (64 bits)
d. 16 bytes (128 bits)
Q:
Recursion is memory-intensive because:
a. Recursive functions tend to declare many local variables.
b. Previous function calls are still open when the function calls itself and the activation records of these previous calls still occupy space on the call stack.
c. Many copies of the function code are created.
d. It requires large data values.
Q:
What value does function mystery return when called with a value of 4?
int mystery (int number)
{
if (number <= 1) {
return 1;
}
else {
return number * mystery(number " 1);
}
}
a. 0.
b. 1.
c. 4.
d. 24.
Q:
A recursive function is a function that:
a. Returns a double.
b. Takes 3 arguments.
c. Calls itself, directly or indirectly.
d. Is inside of another function.
Q:
Given the following function template
template <typename T>
T maximum(T value1, T value2)
{
if (value1 > value2) {
return value1;
}
else {
return value2;
}
}
what would be returned by the following two function calls?
maximum(2, 5);
maximum(2.3, 5.2);
a. 5 and a type-mismatch error.
b. 5 and 5.2.
c. 2 and 2.3.
d. Two error messages.
Q:
Which of the following is true of function templates?
a. All function templates begin with the keyword class.
b. Every formal type parameter is preceded by either keyword typename or template.
c. Formal type parameters act as placeholders for built-in types or user-defined types and are used to specify the types of arguments to the function, to specify the return type of the function, and to declare variables within the body of the function definition.
d. A programmer must define a separate function template for each template function specialization to be used in the program.
Q:
If a set of functions have the same program logic and operations and differ only in the data type(s) each receives as argument(s) then a(n) __________ should be used.
a. Overloaded function.
b. Recursive function.
c. Macro.
d. Function template.
Q:
Type-safe linkage is ensured by:
a. Name mangling.
b. Calling the correct function.
c. The agreement of the arguments and parameters.
d. Specifying return types.
Q:
Overloaded functions must have:
a. Different parameter lists.
b. Different return types.
c. The same number of parameters.
d. The same number of default arguments.
Q:
Which of the following does the C++ compiler not examine in order to select the proper overloaded function to call?
a. Types and order of the arguments in the function call.
b. The number of arguments in the function call.
c. The return type of the function.
d. It examines all of the above.
Q:
The unary scope resolution operator is used:
a. To access a global variable when a local variable of the same name is in scope.
b. To access any variable in an outer block when a local variable of the same name is in scope.
c. To access a global variable when it is out of scope.
d. To access a local variable with the same name as a global variable.
Q:
If the function int volume(int x = 1, int y = 1, int z = 1); is called by the expression volume(3), how many default arguments are used?
a. None.
b. One.
c. Two.
d. Three.
Q:
In regards to default arguments, which of the following is false?
a. When an argument is omitted in a function call, the default value of that argument is automatically inserted by the compiler and passed in the function call.
b. They must be the rightmost (trailing) arguments in a function's parameter list.
c. Default values can be constants.
d. Default values cannot be global variables or function calls.
Q:
Call-by-reference can achieve the security of call-by-value when:
a. The value being passed is small.
b. A large argument is passed in order to improve performance.
c. A pointer to the argument is used.
d. The const qualifier is used.
Q:
A reference parameter:
a. Is an alias for its corresponding argument.
b. Is declared by following the parameter's type in the function prototype by an ampersand (&).
c. Cannot be modified.
d. Both (a) and (b).
Q:
When an argument is passed-by-value, changes in the called function __________ affect the original variable's value; when an argument is passed call-by-reference, changes in the called function __________ affect the original variable's value.
a. Do not, do.
b. Do not, do not.
c. Do, do.
d. Do, do not.
Q:
The inline keyword:
a. Increases function-call overhead.
b. Can reduce a function's execution time but increase program size.
c. Can decrease program size but increase the function's execution time.
d. Should be used with all frequently used functions.
Q:
Which of the following is not included in a function's activation record?
a. The return address of its caller function.
b. Parameter values received from its caller.
c. Local variables it has declared.
d. The name of the function.
Q:
An activation record will be popped off the function call stack whenever:
a. A function returns control to its caller.
b. A function calls another function.
c. A function calls itself.
d. A function declares a local variable.
Q:
What happens when two blocks, one nested inside of the other, both declare variables with the same identifier? (Assume that the outer block declares its variable before the opening left-brace of the inner block.)
a. A syntax error occurs.
b. The "outer" variable is hidden while the "inner" variable is in scope.
c. The "outer" variable is irretrievably lost when the "inner" variable is declared.
d. The "inner" declaration is ignored and the "outer" variable has scope even inside the inner block.
Q:
Labels are the only identifiers with:
a. Function scope.
b. File scope.
c. Block scope.
d. Function-prototype scope.
Q:
Which of the following statements creates a uniform_int_distribution object for producing values in the range -10 to 20?
a. uniform_int_distribution<unsigned int> randomInt{20, -10};
b. uniform_int_distribution<unsigned int> randomInt{-10, 20};
c. uniform_int_distribution<int> randomInt{20, -10};
d. uniform_int_distribution<int> randomInt{-10, 20};
Q:
Which of the following is false?
a. An engine implements a random-number generation algorithm that produce pseudorandom numbers.
b. A distribution controls the range of values produced by an engine, the types of those and the statistical properties of the values.
c. The default range of a uniform_int_distribution is from 0 to 32767.
d. C++11 provides many classes that represent various random-number generation engines and distributions.
Q:
Which of the following statements is false?a. An enumeration's constants have integer values.b. An unscoped enum's underlying type is independent of its constants' values but is guaranteed to be large enough to store those values.c. A scoped enum's underlying integral type is int, but you can specify a different type by following the type name with a colon (:) and the integral type. For example, we can specify that the constants in the enum class Status should have type unsigned int, as in enum class Status : unsigned int {CONTINUE, WON, LOST};d. A compilation error occurs if an enum constant's value is outside the range that can be represented by the enum's underlying type.
Q:
Which of the following statements about scoped enumerations is false?a. A scoped enumeration is introduced by the keywords enum class, followed by a type name and a set of identifiers representing integer constants.b. The identifiers in an enum class must be unique, but separate enumeration constants can have the same integer value.c. By convention, you should capitalize the first letter of an enum class's name.d. To reference a scoped enum constant, you must qualify the constant with the scoped enum's type name and the scope-resolution operator (:), as in MaritalStatus:SINGLE.
Q:
Which of the following is not a valid enumeration?
a. enum class Person {ME, YOU, THEM};.
b. enum class Person {ME = 1, YOU = 2, THEM = 3};.
c. enum class Person {ME = 0, YOU = 0, THEM = 0};.
d. enum class Person {ME, YOU, ME};.