Q1: A constructor can specify the return type: a. int. b. string. c. void. d. A constructor cannot specify a return type. ANS: d. A constructor cannot specify a return type. Q2: To execute multiple statements when an if statement’s condition is true, enclose those statements in a pair of: Parentheses, ( ). Square Brackets, [ ]. Braces, { }. Angle brackets, < >. ANS: c. Braces, { }. Q3: Which of the following is a double-selection statement? if. if…else. do…while. switch. ANS: b. if…else. Q4: How many times will the following loop print hello? i = 1; while ( i <= 10 ) cout << "hello"; 0. 9. 10. An infinite number of times. ANS: d. An infinite number of times. Q5: Having a loop within a loop is known as: Recursion. Doubling up. Nesting. Stacking. ANS: c. Nesting. Q6: If x initially contains the value 3, which of the following sets x to 7? x ++ 4; x += 4; x =+ 4; x + 4 = x; ANS: b. x += 4; Q7: Assuming that x is equal to 4, which of the following statements will not result in y containing the value 5 after execution? y y y y ANS: b. y = = = = = 5; x++; ++x; x + 1 x++; Q8: What will the following program segment do? int counter = 1; do { cout << counter << " "; } while ( ++counter <= 10 ); a. b. Print the numbers 1 through 11. Print the numbers 1 through 10. c. Print the numbers 1 through 9. d. Cause a syntax error. ANS: b. Print the numbers 1 through 10. Q9: Which of the following is not a valid enumeration statement? a. Enum person { me, you, them };. b. Enum person { me = 1, you = 2, them = 3 };. c. Enum person { me = 0, you = 0, them = 0 };. d. Enum person { me, you, me };. ANS: d. Enum person { me, you, me };. Q10: Which of the following is false about the following function prototype? void functionA( void ); a. b. It does not receive any arguments. It could have been written void functionA( );. c. It does not return a value. d. It could have been written functionA( void );. ANS: d. It could have been written functionA( void );. Q11: 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. ANS: b. Can reduce a function’s execution time but increase program size. Q12: 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. Do not, do. Do not, do not. Do, do. Do, do not. ANS: a. Do not, do. Q13: 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. Overloaded function. Recursive function. Macro. Function template. ANS: d. Function template. Q14: Given the following function template template < class 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 ); 5 and a type-mismatch error. 5 and 5.2. 2 and 2.3. Two error messages. ANS: b. 5 and 5.2. Q15: A recursive function is a function that: Returns a double. Takes 3 arguments. Calls itself, directly or indirectly. Is inside of another function. ANS: c. Calls itself, directly or indirectly. Q16: Assuming the following pseudocode for the Fibonacci series, what is the value of the 5th Fibonacci number (fibonacci ( 5 ))? fibonacci( 0 ) = 0 fibonacci( 1 ) = 1 fibonacci( n ) = fibonacci( n – 1 ) + fibonacci( n – 2 ) 1. 3. 5. 7. ANS: c. 5. Q17: A class-scope variable hidden by a block-scope variable can be accessed by preceding the variable name with the class name followed by: :: : . -> ANS: a. :: Q18: If the line: friend class A; appears in class B, and the line: friend class B; appears in class C, then: a. Class A is a friend of class C. b. Class A can access private variables of class B. c. Class C can call class A’s private member functions. d. Class B can access class A’s private variables. ANS: b. Class A can access private variables of class B. Q19: Variables defined inside a member function of a class have: File scope. Class scope. Block scope. Class or block scope, depending on whether the binary scope resolution operator (::) is used. ANS: c. Block scope Q20: The assignment operator (=) can be used to: Test for equality. Copy data from one object to another. Compare two objects. Copy a class. ANS: b. Copy data from one object to another.