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:
Enumeration constants:
a. Must have unique integer values.
b. Can be assigned other values once they"ve been defined.
c. Must have unique identifiers.
d. Are declared using the keyword const.
Q:
To make numeric literals more readable, C++14 allows you to insert between groups of digits in numeric literals the digit separator ' (a single-quote character).
a. , (a comma)
b. ^ (a caret)
c. ' (a single quote)
d. * (an asterisk)
Q:
Which of the following is true?
a. C++ does not provide any capabilities for generating random numbers that cannot be predicted.
b. C++11 provides random number capabilities that can produce nondeterministic random numbersa set of random numbers that can"t be predicted.
c. Random numbers produced by the rand function are nondeterministic.
d. None of the above.
Q:
In the expression
n = x + rand() % y;
a. y is the shifting value.
b. x is the scaling value.
c. y is the scaling value.
d. Both (a) and (b).
Q:
A variable that can have values only in the range 0 to 65535 is a:
a. Four-byte int.
b. Four-byte unsigned int.
c. Two-byte int.
d. Two-byte unsigned int.
Q:
The rand function generates a data value of the type:
a. unsigned int.
b. int.
c. long int.
d. short int.
Q:
Which of the following C++ Standard Library headers does not contain a C++ Standard Library container class?
a. <vector>.
b. <list>.
c. <stack>.
d. <string>.
Q:
Each standard library has a corresponding:
a. Function.
b. Variable type.
c. Header.
d. CD-ROM.
Q:
Converting from type ________ to type ________ will result in the loss of data.
a. bool, char.
b. float, double.
c. int, char.
d. short, long.
Q:
A function prototype can always be omitted when:
a. A function is defined before it is first invoked.
b. A function is invoked before it is first defined.
c. A function takes no arguments.
d. A function does not return a value.
Q:
A function prototype does not have to:
a. Include parameter names.
b. Terminate with a semicolon.
c. Agree with the function definition.
d. Match with all calls to the function.
Q:
The argument list of a function call must match, or be consistent with, the parameter list of the called function in all of the following details, except:
a. The number of arguments/parameters in the list.
b. The types of arguments/parameters in the list.
c. The names of arguments/parameters in the list.
d. The argument list and parameter list must match in all of the above details.
Q:
Using the following function definition, the parameter list is represented by:
A B (C)
{
D
}
a. A.
b. B.
c. C.
d. D.
Q:
The function prototype
double mySqrt(int x);
a. Declares a function called mySqrt which takes an integer as an argument and returns a double.
b. Defines a function called double which calculates square roots.
c. Defines a function called mySqrt which takes an argument of type x and returns a double.
d. Declares a function called mySqrt which takes a double as an argument and returns an integer.
Q:
Which of the following is not included in <cmath>?
a. pow.
b. floor.
c. ln.
d. log.
Q:
Which of the following expressions returns the trigonometric sine of x?
a. sin(x).
b. sine(x).
c. trig_sin(x).
d. trig_sine(x).
Q:
Functions can:
a. Be used as building blocks to create new programs.
b. Return a result to the caller function.
c. Be reused any number of times.
d. Do all of the above.
Q:
All of the following are true of functions except:
a. They define specific tasks that can be used at many points in a program.
b. A function call must specify the name and arguments of the function.
c. The definition of a function usually is visible to other functions.
d. The implementation of a function is hidden from the caller.
Q:
The OR (||) operator:
a. Has higher precedence than the AND (&&) operator.
b. Stops evaluation upon finding one condition to be true.
c. Associates from right to left.
d. Is a ternary operator.
Q:
In C++, the condition (4 > y > 1):
a. Evaluates correctly and could be replaced by (4 > y && y > 1).
b. Does not evaluate correctly and should be replaced by (4 > y && y > 1).
c. Evaluates correctly and could not be replaced by (4 > y && y > 1).
d. Does not evaluate correctly and should not be replaced by (4 > y && y > 1).
Q:
Which of the following is false?
a. The effects of break and continue statements can be achieved by structured programming techniques.
b. break and continue statements can make a program perform faster than with the corresponding structured techniques.
c. Many programmers feel that break and continue violate structured programming.
d. You should always try to write the fastest, smallest code possible before attempting to make it simple and correct.
Q:
Which of the following is false?a. break and continue statements alter the flow of control.b. continue statements skip the remaining statements in current iteration of the body of the loop in which they are embedded.c. break statements exit from the loop in which they are embedded.d. continue and break statements may be embedded only within iteration statements.
Q:
Which of the following is true?
a. You can initialize data members of a class only in the class's constructor.
b. C++11 allows you to provide a default value for a data member when you declare it in the class declaration.
c. You cannot initialize data members of a class.
d. None of the above
Q:
Which of the following data types can be used to represent integers?
a. char
b. long
c. short
d. All of the above.
Q:
switch can be used to test:
a. int constants.
b. float constants.
c. string constants.
d. all types of constants.
Q:
Which of the following is correct when labeling cases in a switch structure?
a. case1:
b. Case1:
c. case 1:
d. Case 1:
Q:
In a switch statement:
a. A break is required after each case.
b. Multiple actions in a case do not need to be enclosed in braces.
c. A default case is required.
d. A break is required after the default case.
Q:
A switch statement should be used:
a. As a single-selection structure.
b. As a double-selection structure.
c. As a multiple-selection structure.
d. To replace all ifelse statements.
Q:
What will the following program segment do?
int counter{1};
do
{
cout << counter << " ";
} while (++counter <= 10);
a. Print the numbers 1 through 11.
b. Print the numbers 1 through 10.
c. Print the numbers 1 through 9.
d. Cause a syntax error.
Q:
If a dowhile structure is used:
a. An infinite loop cannot take place.
b. Counter-controlled iteration is not possible.
c. The body of the loop will execute at least once.
d. An off-by-one error cannot occur.
Q:
Which of the following is false?
a. There are representational errors, when precise decimal dollar amounts and interest rates are stored as doubles.
b. There are many currencies worldwide, with different conventions for thousands separators, decimal separators, currency symbols, and more.
c. C++11's long long type supports values in the range "2,147,483,647 to 2,147,483,647 as a minimum.
d. C++11's int64_t type supports the exact range "9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.
Q:
Which of the following is a parameterized stream manipulator used to format output?
a. setw
b. right
c. left
d. fixed
Q:
float and double variables should be used:
a. To perform monetary calculations.
b. As counters.
c. To store true/false values.
d. As approximate representations of decimal numbers.
Q:
Which of the following for headers is not valid?a. for (int i{0}; i < 10; i++)b. int i{0}; for (; i < 10; i++)c. for (int i{0}; int j{5}; ; i++)d. All of the above.
Q:
Which of the following for headers produces the values from 27 through 3, decrementing by 3?
a. for (unsigned int i{27}; i <= 3; i += 3)
b. for (unsigned int i{27}; i >= 3; i -= 3)
c. for (unsigned int i{27}; i > 3; i -= 3)
d. All of the above.
Q:
Consider the execution of the following for loop
for (int x = 1; x < 5; increment) {
cout << x + 1 << endl;
}
If the last value printed is 5, which of the following might have been used for increment?
a. x++
b. x += 1
c. ++x
d. Any of the above.
Q:
Which of the following is false?
a. The three expressions in the for structure are optional.
b. The initialization and increment expressions can be comma-separated lists.
c. You must declare the control variable outside of the for loop.
d. A for loop can always be used to replace a while loop, and vice versa.
Q:
If a variable is declared in the initialization expression of a for statement, then:
a. It is automatically reinitialized to zero once the loop is finished.
b. The scope of the variable is restricted to that for loop.
c. It retains its final value after the loop is finished.
d. It can not be used in any structures that are nested in that for structure.
Q:
Which of the following is a poor programming practice?
a. Indenting the statements in the body of each control structure.
b. Using floating-point values for counters in counter-controlled iteration.
c. Nesting multiple iteration structures.
d. Placing vertical spacing above and below control structures.
Q:
Which of the following does counter-controlled iteration require?
a. An initial value.
b. A condition that tests for the final value.
c. An increment or decrement by which the control variable is modified each time through the loop.
d. All of the above.
Q:
Which of the following is not one the rules for forming structured programs?
a. Begin with the "simplest activity diagram."
b. Any transition arrow can be reversed.
c. Any action state can be replaced by two action states in sequence.
d. Any action state can be replaced by any control statement.
Q:
Which of the following is not one of the C++ control structures?
a. if
b. switch
c. break
d. dowhile
Q:
The ____________, __________ and ____________ are the only three forms of control necessary.
a. switch, if, else.
b. sequence, selection, iteration.
c. break, continue, ifelse.
d. for, while, dowhile.
Q:
Of the following, which is not a logic error?
a. Not placing curly braces around the body of an if that contains two statements.
b. Using == to assign a value to a variable.
c. Failing to initialize counter and total variables before the body of a loop.
d. Using commas instead of the two required semicolons in a for header.
Q:
Consider the following code, assuming that x is an int with an initial value of 12
if(x = 6) {
cout << x;
}
What is the output?
a. 6
b. 12
c. Nothing.
d. A syntax error is produced.
Q:
Variables are also known as:
a. lvalues, but can be used as rvalues.
b. lvalues, and cannot be used as rvalues.
c. rvalues, and cannot be used as lvalues.
d. Constant variables.
Q:
An example of a unary operator is:
a. The < relational operator.
b. The = assignment operator.
c. The % arithmetic operator.
d. The ! logical operator.
Q:
The expression if (num != 65) cannot be replaced by:
a. if (num > 65 || num < 65)
b. if (!(num == 65))
c. if (num " 65)
d. if (!(num " 65))
Q:
An operator that associates from right to left is:
a. !=
b. ,
c. ()
d. ?:
Q:
Which of the following statements is false?
a. C++ requires all variables to have a type.
b. C++ fundamental types are portable.
c. ints may be 64 bits on some machines.
d. C++ programmers frequently have to write different versions of programs for different platforms.
Q:
Which of the following operations has the highest precedence?
a. Postincrement.
b. Multiplication.
c. Addition.
d. Assignment.
Q:
Assuming that x is equal to 4, which of the following statements will not result in y containing the value 5 after execution?a. y = 5;b. y = x++;c. y = ++x;d. y = x + 1
Q:
Which of the following will not increment c by 1?a. c + 1;b. c++;c. ++c;d. c += 1;
Q:
Assuming that x and y are equal to 3 and 2, respectively, after the statement x -= y executes, the values of x and y will be:a. x: 5; y: 3b. x: 3; y: -1c. x: 3; y: 5d. x: 1; y: 2
Q:
If x initially contains the value 3, which of the following sets x to 7?a. x ++ 4;b. x += 4;c. x =+ 4;d. x + 4 = x;
Q:
Which of the following is true?a. Assigning a double value to an int does not lose any data.b. For fundamental-type variables, list-initialization syntax prevents narrowing conversions that could result in data loss.c. For fundamental-type variables, list-initialization syntax allows narrowing conversions that could result in data loss.d. None of the above.
Q:
[C++11]: Which of the following statements initializes the unsigned int variable counter to 10?
a. unsigned int counter = 10;
b. unsigned int counter = {10};
c. unsigned int counter{10};
d. All of the above.
Q:
Having a loop within a loop is known as:a. Recursion.b. Doubling up.c. Nesting.d. Stacking.
Q:
Which operation does not take place in the following example?int x{21};double y{6};double z{14};y = x / z;x = 5.5 * y;a. Implicit conversion.b. Promotion.c. Explicit conversion.d. Truncation.
Q:
What is the final value of x after performing the following operations?
int x{21};
double y{6};
double z{14};
y = x / z;
x = 5.5 * y;
a. 8.25.
b. 5.5.
c. 5.
d. 8.
Q:
Using a while loop's counter-control variable in a calculation after the loop ends often causes a common logic error called:
a. A fatal logic error.
b. A counter exception.
c. A syntax error.
d. An off-by-one error.
Q:
An uninitialized local variable contains:
a. The value last stored in the memory location reserved for that variable.
b. No value.
c. A value of zero.
d. A randomly assigned value.
Q:
How many times will the following loop print hello?
i = 1;
while (i <= 10) {
cout << "hello";
}
a. 0.
b. 9.
c. 10.
d. An infinite number of times.
Q:
What is wrong with the following while loop?while (sum <= 1000) {sum = sum " 30;}a. The parentheses should be braces.b. There should be a semicolon after while (sum <= 1000).c. sum = sum " 30 should be sum = sum + 30 or else the loop may never end.d. None of the above.
Q:
Which of the following statements about nested ifelse statements is true?a. An ifelse statement may not be nested in another nested ifelse.b. Each ifelse statement must contain only a simple condition.c. In an if body, an inner ifelse executes only if the outer if statement's condition is true.d. The statement(s) in an inner if always execute(s) if its condition is true.
Q:
A block:
a. Must contain exactly three statements.
b. Cannot contain declarations.
c. Is a compound statement.
d. Is represented by placing a semicolon (;) where a statement would normally be.
Q:
Which of the following does not display correct if answer is equal to 7 and incorrect if answer is not equal to 7?a. if (answer == 7) {cout << "correct";}else {cout << "incorrect";}b. cout << answer == 7 ? "correct" : "incorrect";c. cout << (answer == 7 ? "correct" : "incorrect");d. answer == 7 ? cout << "correct" : cout << "incorrect";
Q:
The conditional operator (?:):
a. Is the only ternary operator in C++.
b. Is a unary operator.
c. Associates from left to right.
d. Accepts two operands.
Q:
The data type bool:a. Can take on values true and false.b. Can take on any expression as a value.c. Can take on values -1, 0 or 1.d. Can only be used in a selection statement.
Q:
If grade has the value of 60, what will the following code display?if (grade >= 60) {cout << "Passed";}a. nothing.b. 60c. Passedd. cout << "Passed";
Q:
Which of the following is not a keyword that was added to C++ in the new C++11 standard?a. nullptr.b. operator.c. constexpr.d. noexcept.
Q:
Which of the following is a repetition structure?a. if.b. ifelse.c. dowhile.d. switch.
Q:
Which of the following is a double-selection statement?
a. if.
b. ifelse.
c. dowhile.
d. switch.
Q:
In an activity diagram for an algorithm, what does a solid circle surrounded by a hollow circle represent?
a. Initial state.
b. Final state.
c. Action state.
d. Transition.
Q:
Which of the following encompasses the other three?
a. Sequence structure.
b. Repetition structure.
c. Control structure.
d. Selection structure.
Q:
Pseudocode normally does not include:
a. Declarations.
b. Input/output.
c. Algorithms.
d. Control structures.
Q:
Which of the following is true of pseudocode?
a. It is executed by the computer.
b. It helps the programmer "think out" a program.
c. It includes declarations and all types of statements.
d. All of the above are false.
Q:
Specifying the order in which statements are to be executed in a computer program is called:
a. An algorithm.
b. Transfer of control.
c. Program control.
d. Pseudocode.
Q:
You can initialize fundamental-type data members in their declarations. This is known as a(n) ________ initializer and was introduced in C++11.
a. explicit
b. implicit
c. global
d. in-class initializer
Q:
Which of the following statements is false?
a. Through the use of set and get member functions, you can validate attempted modifications to private data and control how that data is presented to the caller.
b. A client of a class is any other code that calls the class's member functions.
c. Any client code can see a private data member and do whatever it wants with it, including setting it to an invalid value.
d. Tightly controlling the access to and presentation of private data can greatly reduce errors, while increasing the usability, robustness and security of your programs.