Exam2_Review.1

Exam2_Review.1 - b. You want to return more than one value...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
CPSC 121 Exam 2 Review Multiple Choice 1. A while loop may be rewritten as a for loop: a. Always b. Only if there is a variable in the while loop which is incremented c. Only if there is not a variable in the while loop which is incremented d. Only if the number of iterations can be determined in advance e. Never 2. What is the final value of z after this code executes? a. 2.0 int x = 5; int y = 2; double z = 4; z = x / y; b. 2.5 c. 4.0 d. 5.0 e. 7.0 3. cerr is a standard output stream that can be used for diagnostic output and debugging. a. True b. False 4. Passing an argument to a function by value means a. The function does not know the argument’s type b. The function receives a copy of the argument c. The function can alter the argument in the calling statement d. That the keyword const is required e. None of the above 5. You should use pass-by-reference in a function if a. You want the function to be able to change the value of an argument back in the calling function
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: b. You want to return more than one value from the function c. You want to efficiently pass a large data type (like a large vector) to the function d. Both (a) and (b) are correct e. All of the above are correct 6. In a class a. All data elements and functions should be private to maximize security (prevent access to viruses). b. All data elements and functions should be public to maximize flexibility and ease of use. c. Nearly all data elements should be private and most functions should be public. d. Nearly all data elements should be public and most functions should be private. e. All data must be private, but functions are neither public nor private. 7. The primary purpose of a class constructor is to a. Build the class by identifying all of the required components. b. Initialize the values of data elements in objects of the class. c. Allocate enough memory for an object of the class....
View Full Document

Ask a homework question - tutors are online