COMP 35589

subject Type Homework Help
subject Pages 10
subject Words 1187
subject Authors Harvey Deitel, Paul Deitel

Unlock document.

This document is partially blurred.
Unlock all pages and 1 million more documents.
Get Access
page-pf1
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.
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.
page-pf2
Which of the following statements does not overwrite a preexisting value stored in a
memory location?
a. int a;
b. number = 12;
c. y = y + 2;
d. width = length;
Assuming that text is a variable of type string, what will be the contents of text after the
statement cin >> text; is executed if the user types Hello World! then presses Enter?
a. "H"
b. "Hello"
c. "Hello World"
d. "Hello World!"
Which of the following does not cause a syntax error to be reported by the C++
compiler?
a. Mismatched {}.
page-pf3
b. Missing */ in a comment.
c. Missing ; at the end of a statement.
d. Extra blank lines.
The return type ________ indicates that when a function completes its task, it does not
return (i.e., give back) any information to its calling function.
a. null
b. virtual
c. nullptr
d. void
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.
page-pf4
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.
For which of the following operators does C++ not specify the order of evaluation of its
operands?
a. +.
b. &&.
c. ,.
d. ?:.
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.
page-pf5
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
Today, virtually all new major operating systems are written in:
a. Objective-C.
b. C or C++.
c. Visual C#.
d. Ada.
page-pf6
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.
Having a loop within a loop is known as:
a. Recursion.
b. Doubling up.
c. Nesting.
d. Stacking.
page-pf7
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.
Normally, constructors are ________.
a. private
b. protected
c. privy
d. public
Which of the following encompasses the other three?
page-pf8
a. Sequence structure.
b. Repetition structure.
c. Control structure.
d. Selection structure.
Typically, you cannot call a member function of a class until you create a(n) ________
of that class.
a. object
b. image
c. header
d. constructor
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.
page-pf9
d. All of the above are false.
Which of the following statements is false?
a. Each object of a class shares one copy of the class's data members.
b. An object's data members exist before a program calls member functions on an
object, while they are executing and after the member functions complete execution.
c. Data members are declared inside a class definition but outside its member functions'
bodies.
d. Headers should never contain using directives or using declarations.
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.
page-pfa
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.
Pointers cannot be used to:
a. Contain memory addresses.
b. Reference values directly.
c. Pass an argument by reference.
d. Manipulate dynamic data structures.
page-pfb
The linker links:
a. The source code with the object code.
b. The object code with the libraries.
c. The executable code with primary memory.
d. The primary memory with the CPU.
Which of the following is a repetition structure?
a. if.
b. ifelse.
c. dowhile.
d. switch.
Which statement about UML class diagrams is true?
a. UML class diagrams can be used to summarize a class's attributes and operations.
b. In the UML, each class is modeled in a class diagram as a rectangle with three
page-pfc
compartments.
c. The top compartment contains the class name centered horizontally in boldface type
and the middle compartment contains the class's attribute names, which correspond to
the data members of a class.
d. All of the above are true.
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.
Which statement would be used to declare a 10-element integer array c?
page-pfd
a. array c = int[10];
b. c = int[10];
c. int array c[10];
d. int c[10];
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.
page-pfe
c. 2 and 2.3.
d. Two error messages.
________ involves reworking programs to make them clearer and easier to maintain
while preserving their correctness and functionality.
a. Object-oriented programming
b. Refactoring
c. Agile software development
d. LAMP
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.
page-pff
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.
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.

Trusted by Thousands of
Students

Here are what students say about us.

Copyright ©2022 All rights reserved. | CoursePaper is not sponsored or endorsed by any college or university.