Question
QUESTION 1 Passing a structure as a constant reference parameter to a function: A. can potentially result in changes to the structure's members. B. guarantees
QUESTION 1
Passing a structure as a constant reference parameter to a function:
A. | can potentially result in changes to the structure's members. | |
B. | guarantees not to result in changes to the structure's members. | |
C. | will always change the structure's members. | |
D. | All of the above |
QUESTION 2
Before a structure can be used, it must be
A. | declared | |
B. | deallocated | |
C. | initialized | |
D. | All of the above |
QUESTION 3
This allows you to access structure members.
A. | structure access operator | |
B. | dot operator | |
C. | #include | |
D. | getmember function |
QUESTION 4
Which of the following statements outputs the value of the gpa member of element 1 of the student array?
A. | cout << student1.gpa; | |
B. | cout << firstStudent.gpa; | |
C. | cout << student[1].gpa; | |
D. | cout << student1->gpa; |
QUESTION 5
Look at the following structure declaration.
struct Employee
{
string name;
int idNum;
};
In this declaration, Employee is
A. | a member | |
B. | a tag | |
C. | an array | |
D. | None of the above |
QUESTION 6
A struct can contain members with varying data types.
True
False
QUESTION 7
Which of the following headers must be included for class string?
A. | | |
B. | std | |
C. | | |
D. | None of the above |
QUESTION 8
Class string belongs to which namespace?
A. | std | |
B. | | |
C. | | |
D. | All of the above |
QUESTION 9
Class string provides overaloaded ==, !=, <, >, <=, and >= operators for string comparisons
True
False
QUESTION 10
String member function compare compares two strings (or substrings) and returns 0 if:
A. | The strings are not equal | |
B. | the strings are equal | |
C. | if the first string is greater than the second | |
D. | All of the above. |
QUESTION 11
When a derived class has two or more base classes, the situation is knows as :
A. | multiple inheritance | |
B. | polymorphism | |
C. | encapsulation | |
D. | access specification |
QUESTION 12
In the following statement: class Car : protected Vehicle Which is the derived class?
A. | Car | |
B. | Vehicle | |
C. | protected | |
D. | cannot be determined |
QUESTION 13
When member functions behave differently, depending upon which object performed the call, this is an example of:
inheritance | ||
polymorphism | ||
encapsulation | ||
None of the above |
QUESTION 14
In an inheritance situation, you may not pass arguments to a base class constructor.
True
False
QUESTION 15
A member function of a derived class may not have the same name as a member function of a base class
True
False
QUESTION 16
Pointers to a base class may be assigned the address of a derived class object.
True
False
QUESTION 17
In an inheritance situation, the new class that you create from an existing class is known as the:
A. | derived class | |
B. | inheritee | |
C. | child class | |
D. | A and C |
QUESTION 18
Which term allows us to create new classes based on existing classes.
Polymorphism | ||
Inheritance | ||
Function Overloading | ||
The copy constructor |
QUESTION 19
Every preprocessing directive must begin with:
A. | #undef | |
B. | # | |
C. | #define | |
D. | whitespace |
QUESTION 20
The #elif and #else directives are provided as shorthand notation for the #if defined(name) and #if !defined(name).
True
False
QUESTION 21
Which term enables you to control the execution of preprocessing directives and the compilation of program code?
A. | Conditional Compilation | |
B. | Macro | |
C. | #define directive | |
D. | preprocessor |
QUESTION 22
The #undef directive discards symbolic constant and macro names.
True
False
QUESTION 23
namespaces are guaranteed to be unique.
True
False
QUESTION 24
When passing a non-const argument to a const function, the const_cast operator should be used to cast away the "const-ness" of the function.
True
False
QUESTION 25
namespaces cannot have namespaces as members.
True
False
QUESTION 26
What does the term hardware refer to?
A. | The relative difficulty of programming | |
B. | The physical components that a computer is made of | |
C. | The way a computer's storage space is organized | |
D. | The logical flow of instructions |
QUESTION 27
An Integrated Development Environment typically consists of:
A. | A text editor | |
B. | A compiler | |
C. | A debugger | |
D. | All of the above |
QUESTION 28
The programming process consists of several steps, which include:
A. | Input, Processing, and Output | |
B. | Key Words, Operators, and Punctuation | |
C. | Design, Creation, Testing, and Debugging | |
D. | Syntax, Logic, and Error Handling |
QUESTION 29
Programmer-defined names of memory locations that may hold data are:
A. | Operators | |
B. | Variables | |
C. | Syntax | |
D. | Operands |
QUESTION 30
The computer's main memory is commonly known as:
A. | The hard disk | |
B. | The floppy disk | |
C. | RAM | |
D. | Secondary storage |
QUESTION 31
Which of the following is a preprocessor directive?
A. | pay = hours * rate; | |
B. | cin >> rate; | |
C. | int main() | |
D. | #include |
QUESTION 32
In a C++ program, two slash marks ( // ) indicate:
A. | The end of a statement | |
B. | The beginning of a comment | |
C. | The end of the program | |
D. | The beginning of a block of code |
QUESTION 33
What is the output of the following statement?
cout << 4 * (15 / (1 + 3)) << endl;
A. | 15 | |
B. | 12 | |
C. | 63 | |
D. | 72 |
QUESTION 34
How would you consolidate the following declaration statements into one statement?
int x = 7;
int y = 16;
int z = 28;
A. | int x = 7; y = 16; z = 28; | |
B. | int x = 7 y = 16 z = 28; | |
C. | int x, y, z = 7, 16, 28 | |
D. | int x = 7, y = 16, z = 28; |
QUESTION 35
Look at the following program and answer the question that follows it.
1 |
| // This program displays my gross wages. |
2 |
| // I worked 40 hours and I make $20.00 per hour. |
3 |
| #include |
4 |
| using namespace std; |
5 |
|
|
6 |
| int main() |
7 |
| { |
8 |
| int hours; |
9 |
| double payRate, grossPay; |
10 |
|
|
11 |
| hours = 40; |
12 |
| payRate = 20.0; |
13 |
| grossPay = hours * payRate; |
14 |
| cout << "My gross pay is $" << grossPay << endl; |
15 |
| return 0; |
16 |
| } |
Which line(s) in this program cause output to be displayed on the screen?
A. | 13 and 14 | |
B. | 8 and 9 | |
C. | 14 | |
D. | 13 |
QUESTION 36
What is the value stored at x, given the statements:
int x;
x = 3 / static_cast
A. | .3 | |
B. | 0 | |
C. | 0275229 | |
D. | 3.3 |
QUESTION 37
You want the user to enter the length, width, and height from the keyboard. Which cin statement is correctly written?
A. |
cin << length, width, height; | |
B. |
cin.get(length, width, height); | |
C. |
cin >> length >> width >> height; | |
D. |
cin >> length, width, height; |
QUESTION 38
Which statement is equivalent to the following?
number += 1;
A. | number = number + 1; | |
B. | number + 1; | |
C. | number = 1; | |
D. | None of the above |
QUESTION 39
This operator represents the logical AND.
A. | ++ | |
B. | | | | |
C. | && | |
D. | @ |
QUESTION 40
In C++ the = operator indicates:
equality | ||
assignment | ||
subtraction | ||
negation |
QUESTION 41
What will the following segment of code output if 11 is entered at the keyboard?
int number;
cin >> number;
if (number > 0)
cout << "C++";
else
cout << "Soccer";
cout << " is ";
cout << "fun" << endl;
a. | C++ is fun | |
b. | Soccer is fun | |
c. | C++ | |
d. | C++fun |
QUESTION 42
The while loop has two important parts: an expression that is tested for a true or false value, and:
A. | a statement or block that is repeated as long as the expression is true | |
B. | a statement or block that is repeated only if the expression is false | |
C. | one line of code that is repeated once, if the expression is true | |
D. | a statement or block that is repeated once, if the expression is true |
QUESTION 43
This is a collection of statements that performs a specific task.
A. | infinite loop | |
B. | variable | |
C. | constant | |
D. | function |
QUESTION 44
A function is executed when it is
A. | defined | |
B. | prototyped | |
C. | declared | |
D. | called |
QUESTION 45
Given the following function definition
void calc (int a, int& b)
{
int c;
c = a + 2;
a = a * 3;
b = c + a;
}
What is the output of the following code fragment that invokes calc?
(All variables are of type int)
x = 1;
y = 2;
z = 3;
calc(x, y);
cout << x << " " << y << " " << z << endl;
A. | 1 2 3 | |
B. | 1 6 3 | |
C. | 3 6 3 | |
D. | 1 14 9 |
QUESTION 46
A ___________ variable is declared outside all functions.
A. | local | |
B. | global | |
C. | floating-point | |
D. | counter |
QUESTION 47
Which of the following is a valid C++ array definition?
A. | int array[0]; | |
B. | float $payments[10]; | |
C. | void numbers[5]; | |
D. | int array[10]; |
QUESTION 48
A ________ algorithm is a method of locating a specific item of information in a larger collection of data.
A. | sort | |
B. | search | |
C. | standard | |
D. | linear |
QUESTION 49
The statement:
int *ptr;
has the same meaning as
A. | int ptr; | |
B. | *int ptr; | |
C. | int ptr*; | |
D. | int* ptr; |
QUESTION 50
Which statement opens a file and links it to a file stream object?
A. | open(aFile) = link(anObject); | |
B. | file.open("c:\\filename.txt"); | |
C. | linkstream("filename.txt"); | |
D. | link(open(filename.txt")); |
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started