Question 1:
A normal C++ operator that acts in special ways on newly defined data types is said to be
A.
glorified
B.
encapsulated
C.
classified
D.
overloaded
Answer: _________
Question 2:
A function in a derived class that has the same name as a function in the parent class
A.
will override the base class function
B.
will cause an error message to display
C.
will be overridden by the base class function
D.
will execute immediately often the base class function executes
Answer: _________
Question 3:
In which statements, does a 'continue' statements cause the control to go directly to the test condition and then continue the looping process?
A.
'for' and 'while'
B.
'while' and 'if-else'
C.
'do-while' and 'if-else'
D.
'while' and 'do-while'
Answer: _________
Question 4:
Which of the following statements is false?
A.
You typically use a public member function to change the value in a private data member
B.
Because the constructor function does not return a value, you place the keyword void before the constructor's name
C.
The public member functions in a class can be accessed by any program that uses an object created from that class
D.
An instance of a class is considered an object
E.
A class encapsulates all of an object's attributes and behaviors
F.
An example of an attribute is the minutes variable in a time class
G.
An example of a behavior is the setTime function in a time class
H.
A class is considered an object
I.
A function is a block of code that performs a specific task
J.
Functions allow programmers to break large and complex problems into small and manageable tasks
K.
Functions allow programmers to use existing code to perform common tasks
L.
Functions can be called, or invoked, only once in a program
Answer: _________
Question 5:
In a class specifier, data or functions designated private are accessible
A.
to any function in the program
B.
only if you know the password
C.
to member functions of that class
D.
only to public members of the class
Answer: _________
Question 6:
When a function includes a throw statement for errors, the call to the potentially offending function should be placed within a _____ block
A.
throw
B.
try
C.
catch
D.
scope
Answer: _________
Question 7:
The scope resolution operator is
A.
a comma
B.
a semicolon
C.
a colon
D.
two colons
Answer: _________
Question 8:
"C++" is a _____ constant
A.
character literal
B.
named literal
C.
numeric literal
D.
string literal
Answer: _________
Question 9:
In a C++ program, which of the following can be thrown?
A.
scalar variables
B.
programmer-defined objects
C.
both (a) and (b)
D.
neither (a) nor (b)
Answer: _________
Question 10:
The items listed in the function header are called _____
A.
actual arguments
B.
formal parameters
C.
passed parameters
D.
sent arguments
Answer: _________
Question 11:
The first element in a string is
A.
the name of the string
B.
the first character in the string
C.
the length of the string
D.
the name of the array holding the string
Answer: _________
Question 12:
Variables declared outside a block are called _____
A.
global
B.
universal
C.
stellar
D.
external
Answer: _________
Question 13:
The compiler converts your C++ instructions into _____
A.
edited code
B.
object code
C.
source code
D.
translated code
Answer: _________
Question 14:
A fundamental type such as int or double is a _____
A.
programmer-defined type
B.
complex type
C.
nonscalar type
D.
scalar type
Answer: _________
Question 15:
The return type you code for all constructors is _____
A.
void
B.
the class type
C.
the same type as the first data member defined in the class
D.
no type
Answer: _________
Question 16:
When an object-oriented program detects an error within a function, the function _________
A.
throws an exception
B.
throws a fit
C.
catches a message
D.
catches an exception
Answer: _________
Question 17:
Using a statement at the wrong time or with an inappropriate object creates a
A.
logical error
B.
syntax error
C.
compiler error
D.
language error
Answer: _________
Question 18:
When you create a derived class and instantiate an object _____
A.
the parent class object must be constructed first
B.
the child class object must be constructed first
C.
the parent class object must not be constructed
D.
the child class object must not be constructed
Answer: _________
Question 19:
Evaluate the following expression: 4 >6 || 10 < 2 * 6
A.
True
B.
False
Answer: _________
Question 20:
A constructor always has
A.
communicational cohesion
B.
temporal cohesion
C.
logical cohesion
D.
no cohesion
Answer: _________
Question 21:
Which of the following is an access specifier?
A.
particular
B.
shielded
C.
protected
D.
safe
Answer: _________
Question 22:
Machine code is _____
A.
edited code
B.
source code
C.
the 0s and 1s that the computer can understand
D.
both (b) and (c)
Answer: _________
Question 23:
The contents of two pointers that point to adjacent of type float differ by
A.
one bytes
B.
two bytes
C.
three bytes
D.
four bytes
Answer: _________
Question 24:
Which of the following is a valid condition for an if statement? (The condition should be both syntactically and logically valid.)
A.
(age) > 65
B.
(age > 0 and < 10)
C.
(sales > 500 && < 800)
D.
(sales > 100 && sales <= 1000)
Answer: _________
Question 25:
A pattern for creating an object is called a(n) _____
A.
class
B.
attributes
C.
private
D.
public
Answer: _________
Question 26:
An asterisk placed after a data type means
A.
array to
B.
pointer to
C.
address to
D.
located to
Answer: _________
Question 27:
An object is a(n) _____ of a class
A.
owner
B.
function
C.
definition
D.
instance
Answer: _________
Question 28:
The function printDataMembers() is not likely a(n) ________
A.
inspector functions
B.
mutator functions
C.
auxiliary functions
D.
manager functions
Answer: _________
Question 29:
When you write to a file rather than the screen, you use the C++ class _____
A.
iostream
B.
filed
C.
fstream
D.
diskclass
Answer: _________
Question 30:
Which of the following numerical value(s) is(are) invalid constant(s)?
A.
0.7
B.
9.3el2
C.
27,512
D.
12345678
Answer: _________
Question 31:
A do-while loop contains
A.
only one statement between the do statement and the while statement
B.
several statements between the do statement and the while statement
C.
no statement at all between the do statement and the while statement
D.
only two statement between the do statement and the while statement
Answer: _________
Question 32:
The braces that surround the code in a 'C program
A.
show what code goes in a particular function
B.
delimit a section of code
C.
separate the codes from the constant
D.
separate the source file from the subject file
Answer: _________
Question 33:
The indirection operator is the
A.
asterisk
B.
ampersand
C.
dollar sign
D.
plus sign
Answer: _________
Question 34:
Local variables _____
A.
are created outside a block
B.
are known only to that block
C.
continue to exist when their block ends
D.
are illegal in C++
Answer: _________
Question 35:
# directives must be present
A.
before the main() function
B.
after the main() function
C.
at the end of the program
D.
anywhere in the program body
Answer: _________
Question 36:
Programmers prefer to declare almost all variables _____
A.
at the beginning of each function
B.
globally
C.
on one line
D.
with cryptic names
Answer: _________
Question 37:
Separating parts of a program into units that remain unaffected by other parts of a program is the concept known as _____
A.
intrusion
B.
volatility
C.
encapsulation
D.
protection
Answer: _________
Question 38:
A function whose purpose is to send messages to other functions is known as a _____
A.
dispatcher
B.
courier
C.
messenger
D.
sender
Answer: _________
Question 39:
With commercial classes, the function source code is usually________
A.
printed on high-quality paper
B.
poorly written
C.
provided on a disk
D.
provided in object form
Answer: _________
Question 40:
The type of value that a function sends back to the function that calls it is known as its _____
A.
type
B.
return value
C.
reference data
D.
sentinel
Answer: _________
Question 41:
Which of the following are never inherited?
A.
public data members
B.
constructor functions
C.
void functions
D.
overloaded + operators
Answer: _________
Question 42:
The expression c = i++ causes
A.
the value of i assigned to c and then i incremented by 1
B.
i to be incremented by 1 and then the value of i assigned to c
C.
value of i assigned to c
D.
i to be incremented by 1
Answer: _________
Question 43:
An identifier in C
A.
is a name of a thing such as variable and function
B.
is made up of letters, numerals and the underscore
C.
can contain both uppercase and lowercase letters
D.
All of the above
Answer: _________
Question 44:
The bitwise AND operator is represented by the symbol
A.
^
B.
&
C.
&&
D.
>>
Answer: _________
Question 45:
A difference, between reference variables and pointers is that
A.
reference variables are easier to use
B.
pointers are easier to use
C.
reference variables are more flexible
D.
no difference exists between reference variables and pointers
Answer: _________
Question 46:
A 'C' function does not contain
A.
a function header
B.
argument declarations
C.
other 'C' functions
D.
function body
Answer: _________
Question 47:
_____ variables remain in memory until the program ends
A.
Area
B.
Global
C.
Local
D.
Reference
Answer: _________
Question 48:
The outline or the definition of a function is called its
A.
beta test
B.
forerunner
C.
outline
D.
prototype
Answer: _________
Question 49:
Which of the following is false?
A.
Data stored in an array can be accessed faster than data stored in a disk file
B.
Data stored in an array needs to be entered only once, typically at the beginning of the program
C.
Arrays allow the programmer to store information in the computer's internal memory
D.
When using arrays, you will have fewer variable names to remember
E.
You enclose a function's statements in a set of braces
F.
The function header is considered a C++ statement, so it must end in a semicolon
G.
The keyword void tells the C++ compiler that the function does not return a value
H.
A function can receive information that you send (pass) to it
I.
A pointer variable contains the address of a variable in memory
J.
You should both declare and initialize a pointer before you use it
K.
Pointers are typically initialized to the empty string ("")
L.
A pointer's datatype must match the datatype of the variable to which it points
M.
A void function's header begins with the keyword void
N.
A value-returning function's header begins with a data type, which represents the type of data the function will return
O.
Assuming displayAge is the name of a void function, displayAge()
is a both logically and syntactically valid C++ statement
P.
Assuming calcNewPrice is the name of a value-returning function, calcNewPriceO
is a both logically and syntactically valid C++ statement
Answer: _________
Question 50:
A function stub typically contains
A.
the function header
B.
the function braces
C.
the return statement, if it's value- returning function
D.
a display message
Answer: _________
Question 51:
A variable's _____ indicates which portions of the program can use the variable
A.
area
B.
extent
C.
lifetime
D.
reach
Answer: _________
Question 52:
If an integer object is thrown with a throw statement, then a subsequent catch block has a usable match if the type of the catch argument is _____
A.
const int &
B.
int &
C.
either (a) or (b)
D.
neither (a) nor (b)
Answer: _________
Question 53:
_____ variables are declared outside of any statement block
A.
Area
B.
Global
C.
Local
D.
Reference
Answer: _________
Question 54:
The end of string is recognized by
A.
the null character
B.
the newline character
C.
the $ sign
D.
the / sign
Answer: _________
Question 55:
The exclusive OR operator gives the result 1 when
A.
both the bits are 0
B.
one bit is 0 and the other is 1
C.
both the bits are 1
D.
no hard and fast rule
Answer: _________
Question 56:
A function's purpose is to print customer data. Which of the following is the best name for this function?
A.
pcd(). It's short for "print customer data" and takes few keystrokes
B.
Printcustomerdata(). It states everything the function will do
C.
printCustomer(). It states the function's purpose and is easy to read
D.
lastFunction(). It is the final function called in most programs and this name identifies the function's timing
Answer: _________
Question 57:
The function strcmp("Jose", "JOSE") will return _____
A.
-1
B.
0
C.
1
D.
2
Answer: _________
Question 58:
A pointer to void can hold pointers to
A.
char type
B.
int type
C.
float type
D.
any data type
Answer: _________
Question 59:
Which of the following is the extraction operator?
A.
>>
B.
<<
C.
//
D.
/*
Answer: _________
Question 60:
When a multidimensional array is accessed, each array index is
A.
separated by commas
B.
surrounded by brackets and separated by commas
C.
separated by commas and surrounded by brackets
D.
surrounded by brackets
Answer: _________
Question 61:
To create a variable, you must assign _____ to it
A.
a data type
B.
a name
C.
both a data type and a name
D.
the word var
Answer: _________
Question 62:
You indicate a variable is a pointer variable by placing a(n) _____ in front of the variable's name
A.
asterisk
B.
ampersand
C.
dollar sign
D.
exclamation point
Answer: _________
Question 63:
A function can make_________
A.
one throw
B.
one throw of each scalar type
C.
one throw of each programmer-defined type
D.
as many throws of as many types as necessary
Answer: _________
Question 64:
When a variable exists or is accessible, it is said to be _____
A.
immediate
B.
in the path
C.
available
D.
in scope
Answer: _________
Question 65:
The feature that allows the same operations to be carried out differently depending on the object is _____
A.
polymorphism
B.
polygamy
C.
inheritane
D.
multitasking
Answer: _________
Question 66:
Which of the following is a C++ class?
A.
>>
B.
read()
C.
cin
D.
iostream
Answer: _________
Question 67:
Precedence determines which operator
A.
is evaluated first
B.
is most important
C.
is fastest
D.
operates on the largest number
Answer: _________
Question 68:
When using the standard files that come with the C++ compiler, you should surround the header file name with _____
A.
square brackets
B.
angle brackets
C.
parentheses
D.
quotes
Answer: _________
Question 69:
The loop condition in a flowchart is represented by a(n) _____
A.
diamond
B.
oval
C.
parallelogram
D.
rectangle
Answer: _________
Question 70:
Which of the following, if any, are invalid names for a variable?
A.
bankAccountNumber
B.
first_Name
C.
doubleNumber
D.
operator
Answer: _________
Question 71:
Inheritance is the principle that
A.
classes with the same name must be derived from one another
B.
knowledge of a general category can be applied to more specific objects
C.
C++ functions may be used only if they have logical predecessors
D.
one function name may invoke different methods
E.
Classes with the same name must be derived from one another
F.
Knowledge of a general category can be applied to more specific objects
G.
C++ functions may be used only if they have logical predecessors
H.
One function name may invoke different methods
Answer: _________
Question 72:
You typically initialize a String variable to _____
A.
an asterisk
B.
a space enclosed in single quotes
C.
the number 0
D.
a zero-length string
Answer: _________
Question 73:
The set of instructions for how to tie a bow is an example of the _____ structure
A.
control
B.
repetition
C.
selection
D.
sequence
Answer: _________
Question 74:
Which of the following C++ expressions is equivalent to the mathematical expression 5 3 ?
A.
5 ^ 3
B.
cube(5)
C.
pow(3, 5)
D.
pow(5, 3)
Answer: _________
Question 75:
The right shift operator is represented by the symbol
A.
>
B.
>>
C.
→
D.
<
Answer: _________
Question 76:
In C++, class definitions are most often
A.
stored with each program that uses them
B.
stored in a header file that is included in the programs that use them
C.
stored in a folder that you paste into every new project
D.
retyped for every new project
Answer: _________
Question 77:
The comma operator (,) is primarily used in conjunction with
A.
'for' statement
B.
'if-else' statement
C.
'do-while' statement
D.
All of the above
Answer: _________
Question 78:
To execute a C++ program, you first need to translate the source code into object code. This process is called
A.
coding
B.
compiling
C.
sourcing
D.
translating
Answer: _________
Question 79:
The rules of a programming language are called its _____
A.
code
B.
guidelines
C.
procedures
D.
regulations
Answer: _________
Question 80:
An array element is accessed using
A.
a first-in-first-out approach
B.
the dot operator
C.
a member name
D.
an index number
Answer: _________
Question 81:
The program can access the private members of a class
A.
directly
B.
only through other private members of the class
C.
only through other public members of the class
D.
None of the above - the program cannot access the private members of a class in any way
Answer: _________
Question 82:
To hide a data member from the program, you must declare the data member in the _____ section of the class.
A.
concealed
B.
confidential
C.
hidden
D.
private
Answer: _________
Question 83:
External documentation includes
A.
a printout of the program's code
B.
flowcharts
C.
IPO charts
D.
pseudocode
Answer: _________
Question 84:
Making class members inaccessible to nonmember functions is an example of
A.
polymorphism
B.
data hiding
C.
redundancy
D.
recursion
Answer: _________
Question 85:
Providing two or more constructors for the same class _____
A.
requires different argument lists
B.
requires different constructor names
C.
requires different constructor types
D.
is illegal
Answer: _________
Question 86:
3 is a _____ constant
A.
character literal
B.
named literal
C.
numeric literal
D.
string literal
Answer: _________
Question 87:
_____ variables remain in memory until the statement block ends
A.
Area
B.
Global
C.
Local
D.
Reference
Answer: _________
Question 88:
An address is a _____ , while a pointer is a _____
A.
array, variable
B.
constant, variable
C.
variable, position
D.
variable, location
Answer: _________
Question 89:
Procedural cohesion is similar to sequential cohesion, except that with procedural cohesion _____
A.
the tasks are not done in order
B.
the tasks are simpler
C.
the tasks share data
D.
the tasks do not share data
Answer: _________
Question 90:
The getline() function reads a line of text until _____
A.
the length used as the second argument is reached
B.
the character used as the third argument is reached
C.
either (a) or (b)
D.
neither (a) nor (b)
Answer: _________
Question 91:
The extraction operator >> is a(n)
A.
overloaded function
B.
C++ class
C.
C++ object
D.
static reference variable
Answer: _________
Question 92:
One drawback to returning an error code from a function is _____
A.
functions cannot return error codes
B.
error codes must be integers and some functions can't return an integer
C.
a function can return only one value, so it can return only the error code
D.
a function that returns an error code will identify all returns as errors
Answer: _________
Question 93:
Which functions do not have a this pointer?
A.
access functions
B.
inspector functions
C.
member functions
D.
static functions
Answer: _________
Question 94:
When a program calls a function that has default parameters, if you omit an argument, you must _____
A.
not omit any other arguments
B.
omit all arguments
C.
omit all arguments to the right of that argument
D.
omit all arguments to the left of that argument
Answer: _________
Question 95:
Each generic type in a template function definition is preceded by the keyword _________
A.
template
B.
function
C.
type
D.
class
Answer: _________
Question 96:
The declaration section holds
A.
data members
B.
data members and function prototypes
C.
data members, function prototypes, and the functions themselves
D.
None of the above
Answer: _________
Question 97:
A derived class _____ override attributes of a parent class
A.
may
B.
may if the two classes have the same name
C.
must
D.
must not
E.
may
F.
may if the two classes have the same name
G.
must
H.
must not
Answer: _________
Question 98:
In object-oriented terms, an exception may be considered a(n) _____
A.
child
B.
encapsulation
C.
message
D.
scalar type
Answer: _________
Question 99:
A(n) _____ is a numeric variable used for counting something
A.
accumulator
B.
adder
C.
constant
D.
counter
Answer: _________
Question 100:
The element of an array is
A.
the name of the array
B.
a member of an array
C.
a value assigned to an array
D.
All of the above
Answer: _________
Question 101:
When the function void someFunction(int x) throw(char) is executed,_____
A.
it will throw nothing
B.
it may throw an integer
C.
it may throw a character
D.
it may not throw anything
Answer: _________
Question 102:
When accessing a structure member, the identifier to the left of the dot operator is the name of
A.
a structure member
B.
a structure tag
C.
a structure variable
D.
the keyword struct
Answer: _________
Question 103:
Assume that a program contains a programmer-defined void function. When C++ encounters the function's closing brace (}), C++ returns to the statement _____
A.
immediately above the statement that called the function
B.
that called the function
C.
immediately below the statement that called the function
D.
None of the above
Answer: _________
Question 104:
Inheritance occurs when a class adopts all the traits of _________
A.
an object
B.
a parent class
C.
a variable
D.
a function
Answer: _________
Question 105:
Template classes that have already been written to perform common class tasks are called _____
A.
container classes
B.
receptacle classes
C.
repository classes
D.
alembic classes
Answer: _________
Question 106:
A _____ is a single item of information about a person, place, or thing
A.
data file
B.
field
C.
program file
D.
record
Answer: _________
Question 107:
Which (if any) of the following is NOT a programmer-defined type
A.
an array
B.
a structure
C.
a class
D.
All of the above are programmer-defined types
Answer: _________
Question 108:
A file pointer always contains the address of the file
A.
True
B.
False
Answer: _________
Question 109:
You declare a function with a function _____, which is typically entered at the beginning of the program, below the #include directives
A.
call
B.
prototype declaration
C.
definition
D.
pointer
Answer: _________
Question 110:
A function that is called automatically each time an object is created is a(n)
A.
constructor
B.
contractor
C.
builder
D.
architect
E.
constructor
F.
contractor
G.
builder
H.
architect
Answer: _________
Question 111:
A variable's _____ indicates how long the variable remains in the computer's memory
A.
area
B.
extent
C.
lifetime
D.
reach
Answer: _________
Question 112:
You may override the class access specifier for _____
A.
public members
B.
public and protected members
C.
any specific class members you choose
D.
no class members
Answer: _________
Question 113:
The null character needs a space of
A.
zero bytes
B.
one byte
C.
three bytes
D.
four bytes
Answer: _________
Question 114:
The number of structures than can be declared in a single statement is
A.
one
B.
two
C.
three
D.
unlimited
Answer: _________
Question 115:
The most efficient data type for a variable that stores the letter C is the _____ data type
A.
Character
B.
Double
C.
Float
D.
Long Integer
Answer: _________
Question 116:
The C++ operator used to allocate memory is _________
A.
mem
B.
allocate
C.
new
D.
create
Answer: _________
Question 117:
Assume that your version of C++ can recognize only the first 8 characters of an identifier name, through identifier names may be arbitrarily long. Which of the following identifier names is not distinct:
A.
list, list2
B.
address, Address
C.
identifier_l, identifier_2
D.
answer, ANSWER
Answer: _________
Question 118:
Which loop always processes its instructions at least once?
A.
do-while
B.
for
C.
while
D.
None of the above
Answer: _________
Question 119:
When a new class is derived from an existing class, the derived class member functions _____ have names that differ from base class function names
A.
may
B.
may if the two classes have the same name
C.
must
D.
must not
Answer: _________
Question 120:
A static data member is given a value
A.
within the class definition
B.
outside the class definition
C.
when the program is executed
D.
never
E.
within the class definition
F.
outside the class definition
G.
when the program is executed
H.
never
Answer: _________
Question 121:
_____ refers to the process of locating and removing the errors in a program
A.
Analyzing
B.
Correcting
C.
Debugging
D.
Executing
Answer: _________
Question 122:
Static variables are sometimes called
A.
class variables
B.
functional variables
C.
dynamic variables
D.
auto variables
E.
class variables
F.
functional variables
G.
dynamic variables
H.
auto variables
Answer: _________
Question 123:
You can pass _____ to functions
A.
copies of individual structure members
B.
copies of entire structures
C.
pointers to structures
D.
All of the above
Answer: _________
Question 124:
Element doubleArray[7] is which element of the array?
A.
the sixth
B.
the seventh
C.
the eighth
D.
impossible to tell
Answer: _________
Question 125:
Compared with the classes from which they are derived, inherited classes may have _____
A.
additional data members
B.
additional member functions
C.
both (a) and (b)
D.
neither (a) nor (b)
Answer: _________
Question 126:
Using new may result in less _____ memory than using an array
A.
wasted
B.
used
C.
RAM
D.
ROM
Answer: _________
Question 127:
The most common operation used in constructors is
A.
addition
B.
overloading
C.
assignment
D.
polymorphism
Answer: _________
Question 128:
In a simple 'if' statement with no 'else'. What happens if the condition following the 'if is false?
A.
the program searches for the last else in the program
B.
nothing
C.
control 'falls through' to the statement following 'if
D.
the body of the statement is executed
Answer: _________
Question 129:
If two types of errors may be thrown, you should write _______
A.
no catch blocks
B.
one catch block with two arguments
C.
two catch block-one with an argument, and one without
D.
two catch blocks with one argument each
Answer: _________
Question 130:
The name of a function ends with
A.
double quotes
B.
single quotes
C.
parenthesis
D.
hash
Answer: _________
Question 131:
Which of the following is not a programming control structure?
A.
repetition
B.
selection
C.
sequency
D.
sorting
Answer: _________
Question 132:
The bitwise OR operator is a
A.
unary operator
B.
binary operator
C.
ternary operator
D.
octal operator
Answer: _________
Question 133:
A class Stockltems has four data members and three function members. You define 50 objects as members of the class. Which is true?
A.
Only one copy of each of the three functions exists
B.
Only one copy of each of the four data members exists
C.
Both (a) and (b) are true
D.
Neither (a) nor (b) is true
Answer: _________
Question 134:
The continue statement should be written only
A.
in the body of a loop
B.
in the nested loops
C.
outside the body of a loop
D.
any where
Answer: _________
Question 135:
A major advantage of inheritance is
A.
reducing the time it takes to create new objects
B.
not having to think about how objects will be used
C.
reducing the amount of memory required to execute a progrma
D.
enabling people who have not studied programming to create useful applications
Answer: _________
Question 136:
The number 5.5e3 is a _____ constant
A.
character literal
B.
named literal
C.
numeric literal
D.
string literal
Answer: _________
Question 137:
The compiler determines the type used in a template function via ___________
A.
the name of the function
B.
the first variable declared within the function
C.
the type of the argument passed to the function
D.
the type of the value returned from the function
Answer: _________
Question 138:
Simple routines that programmers use as place holders while a system is being tested are called _____
A.
stubs
B.
stumps
C.
holders
D.
templates
Answer: _________
Question 139:
You can place function templates
A.
at the end of main()
B.
at the start of a program above main()
C.
in two files-one for the definition and one for the function
D.
any of the above
Answer: _________
Question 140:
The two operators && an || are
A.
arithmetic operators
B.
equality operators
C.
logical operators
D.
relational operators
Answer: _________
Question 141:
The arguments that determine the state of the cout object are called _____
A.
classes
B.
manipulators
C.
format flags
D.
state controllers
Answer: _________
Question 142:
The variables declared in a statement block or listed in a function header's parameterlist are considered _____ variables
A.
area
B.
global
C.
local
D.
reference
Answer: _________
Question 143:
An expression
A.
is a collection of data objects and operators that can be evaluated to a single value
B.
is a name that substitutes for a sequence of characters
C.
causes the computer to carry out some action
D.
All of the above
Answer: _________
Question 144:
In the C language, the character type of constant is delimited by using
A.
single quotes
B.
double quotes
C.
parenthesis
D.
hash
Answer: _________
Question 145:
To create a template class, you begin with _________
A.
the template definition
B.
the keyword class
C.
the function definitions
D.
the keyword definition
Answer: _________
Question 146:
Which of the following is a C++ object?
A.
>>
B.
read()
C.
cin
D.
iostream
E.
cin
F.
>>
G.
iostream
H.
read()
Answer: _________
Question 147:
A variable is _____
A.
an item of data
B.
a memory location whose value can change while the program is running
C.
a memory location whose value cannot change while the program is running
D.
None of the above
Answer: _________
Question 148:
A function can
A.
return a value
B.
perform a task
C.
change value of actual arguments in call by reference
D.
a, b, c above are all true
Answer: _________
Question 149:
A constructor initialization list is preceded by _____
A.
a semicolon
B.
a colon
C.
two colons
D.
a space
Answer: _________
Question 150:
When the compiler places a copy of a small function's statements directly into a program, the function is said to be _____
A.
overloaded
B.
mangled
C.
inline
D.
redundant
Answer: _________
Question 151:
A group of related fields that contain all of the data about a specific person, place, or thing is called a
A.
data file
B.
field file
C.
program file
D.
record
Answer: _________
Question 152:
To send output to a file, you need to include the _____ header file in your program
A.
file.h
B.
fstream.h
C.
iomanip.h
D.
iostream.h
Answer: _________
Question 153:
A C++ _____ is a program that runs in a DOS window
A.
algorithm
B.
cast application
C.
console application
D.
source application
Answer: _________
Question 154:
A(n) _____ is always incremented by a constant amount, whereas a(n) _____ is incremented by an amount that varies
A.
accumulator, counter
B.
counter, accumulator
C.
accumulator, accumulator
D.
counter, counter
Answer: _________
Question 155:
The C++ _____ function generates random numbers
A.
generate()
B.
genRand
C.
rand
D.
randGen
Answer: _________
Question 156:
If you wanted to sort many large objects or structures, it would be most efficient to
A.
place them in an array and sort the array
B.
place pointers to them in an array and sort the array
C.
place them in a linked list and sort the linked list
D.
place references to them in an array and sort the array
Answer: _________
Question 157:
The printer can be accessed using the predefined filename _____
A.
printer file
B.
print
C.
cout
D.
PRN, LPT1, etc
Answer: _________
Question 158:
The best functions have _____
A.
high cohesion and tight coupling
B.
high cohesion and loose coupling
C.
low cohesion and tight coupling
D.
low cohesion and loose coupling
Answer: _________
Question 159:
One of the valid escape sequences used in the C language is
A.
z
B.
N
C.
s
Answer: _________
Question 160:
A default constructor
A.
takes no arguments
B.
has default values for all its arguments
C.
either (a) or (b)
D.
neither (a) nor (b)
Answer: _________
Question 161:
You can code a default exception handler by creating a catch block
A.
with no arguments
B.
with a void argument
C.
with an ellipsis as its argument
D.
with an argument identical to that thrown
Answer: _________
Question 162:
Which of the following are void functions?
A.
main
B.
pow
C.
sqrt
D.
All of the above
Answer: _________
Question 163:
Hiding individual components of an entry is _____
A.
polymorphism
B.
encapsulation
C.
scaling
D.
not recommended in C++
Answer: _________
Question 164:
When all of the operations in a function contribute to the performance of only one task, a function has
A.
singular cohesion
B.
tight cohesion
C.
functional cohesion
D.
sequential cohesion
Answer: _________
Question 165:
A function that uses variable types is called __________
A.
overloaded
B.
a template function
C.
a variable function
D.
a virtual function
Answer: _________
Question 166:
Having more than one function with the same name is called
A.
overloading
B.
defaulting
C.
casting
D.
referencing
Answer: _________
Question 167:
An object is _____
A.
a category of classes
B.
a name given to a class
C.
an instance of a class
D.
the same as a class
Answer: _________
Question 168:
Two access specifers in C++ are
A.
public and private
B.
int and double
C.
formal and informal
D.
void and free
Answer: _________
Question 169:
A data member holds a 1 or 0 depending on whether taxes have been paid. The best identifier for this member is _____
A.
taxes
B.
paidTaxes
C.
taxesArePaid
D.
code
Answer: _________
Question 170:
Assume a class Derv that is privately derived from class Base. An object of class Derv located in main() can access
A.
public members of Base
B.
protected members of Base
C.
private members of Base
D.
public members of Derv
Answer: _________
Question 171:
Which of the following is the scope resolution operator?
A.
→›
B.
::
C.
*
D.
&
Answer: _________
Question 172:
If the description of function is "input the quantity, validate that the quantity is greater than 1, subtract 1 from the quantity and print the quantity," the function is
A.
sequentially cohesive
B.
logically cohesive
C.
communicationally cohesive
D.
functionally cohesive
Answer: _________
Question 173:
A function that changes an object's state belongs to the category of
A.
inspector functions
B.
mutator functions
C.
auxiliary functions
D.
manager functions
Answer: _________
Question 174:
Which of the following pairs of identifier name(s) are(is) considered to be identical?
A.
name, names
B.
smith, johnsmith
C.
identifier 1, identifier_2
D.
charl, char_l
Answer: _________
Question 175:
When you create a derived class and instantiate on object
A.
the parent class object must be constructed first
B.
the child class object must be constructed first
C.
the parent class object must not be constructed
D.
the child class object must not be constructed
Answer: _________
Question 176:
The int type of constants are whole numbers in the range
A.
-23677 to 23678
B.
-32768 to 32767
C.
-32767 to 32768
D.
-32864 to 32865
Answer: _________
Question 177:
When the function char someFunction(int x) is executed,
A.
it will throw nothing
B.
it will throw an integer
C.
it will throw a character
D.
it may or may not throw anything
Answer: _________
Question 178:
One way in which a structure differs from an array is that
A.
a structure may have members of more than one type
B.
a structure must have members that are all the same type
C.
an array may have members of more than one type
D.
there is no difference between a structure and an array
Answer: _________
Question 179:
Variables that hold memory addresses are called _____
A.
subscripts
B.
holders
C.
pointers
D.
indicators
Answer: _________
Question 180:
The function stricmp("Jose", "JOSE") will return _____
A.
-1
B.
0
C.
1
D.
2
Answer: _________
Question 181:
Which is true?
A.
Coincidental cohesion is stronger than procedural cohesion
B.
Logical cohesion is stronger than coincidental cohesion
C.
Sequential cohesion is weaker than temporal cohesion
D.
The weakest cohesion is functional
E.
Sequential cohesion is slightly weaker than functional cohesion
F.
Sequential cohesion is slightly stronger than functional cohesion
G.
Sequential cohesion is much stronger than functional cohesion
H.
Neither sequential cohesion nor functional cohesion is stronger than the other
Answer: _________
Question 182:
A predefined function that may be used to handle memory allocation errors is
A.
handle_error
B.
set_new_handler
C.
new_fix
D.
memory_error
Answer: _________
Question 183:
A function in a derived class that has the same name as a function in the parent class _____
A.
will cause an error message to display
B.
will override the base class function
C.
will be overridden by the base class function
D.
will execute immediately after the base class function executes
Answer: _________
Question 184:
The _____ function returns the uppercase equivalent of a character
A.
caseupper
B.
charupper
C.
toupper
D.
uCase
Answer: _________
Question 185:
When you instantiate a derived class object, a constructor for the derived class _____
A.
is not called
B.
is called prior to the base class constructor
C.
is called simultaneously with the base class constructor
D.
None of the above
Answer: _________
Question 186:
A constructor may be _____
A.
provided automatically by C++
B.
written by you
C.
either (a) or (b)
D.
neither (a) nor (b)
Answer: _________
Question 187:
Software that can be used in applications other than the one for which it was originally written is called
A.
recyclable
B.
inherited
C.
reusable
D.
cheating
Answer: _________
Question 188:
Typing the function's name as Main, rather than main, is an example of
A.
an entry error
B.
a function error
C.
a logic error
D.
a syntax error
Answer: _________
Question 189:
The difference between a return and a throw is that _____
A.
with a throw, no value can be sent
B.
with a return, no value can be sent
C.
with a throw, execution takes place at the location from which the function was called
D.
with a return, execution takes place at the location from which the function was called
Answer: _________
Question 190:
Which is a good reason for passing a variable's address to a function?
A.
the function will have a copy of the variable
B.
the function cannot change the value of the variable in the calling function
C.
C++ requires that all variables used in a function be passed by address
D.
the function needs to change multiple variable values
Answer: _________
Question 191:
The string HELLO WORLD needs
A.
11 bytes
B.
12 bytes
C.
10 Bytes
D.
8 bytes
Answer: _________
Question 192:
Library header files usually contain
A.
complete functions
B.
parts of functions
C.
function prototypes for functions stored in other files
D.
function bodies, but not function headers
Answer: _________
Question 193:
A C++ term meaning "generic" is
A.
argument
B.
parameterized
C.
universal
D.
global
Answer: _________
Question 194:
Before object-oriented exception handling was practiced, _____
A.
no run-time errors occurred
B.
programmers could not deal with run-time errors
C.
the most popular error-handling method was to terminate the program
D.
the most popular error-handling method was to throw an exception
Answer: _________
Question 195:
The preprocessor directive always ends with
A.
a comma
B.
a semicolon
C.
neither a semicolon nor a comma
D.
"/"
Answer: _________
Question 196:
A constructor initialization list produces similar results to
A.
overriding
B.
assignment
C.
redeclaring
D.
output
Answer: _________
Question 197:
Which of the following stream manipulators advances the cursor to the next line on the computer screen?
A.
adin
B.
advin
C.
edlin
D.
endl
Answer: _________
Question 198:
6.5 is a _____ constant
A.
character literal
B.
named literal
C.
numeric literal
D.
string literal
Answer: _________
Question 199:
When the compiler cannot differentiate between two overloaded constructors, they are called
A.
overloaded
B.
destructed
C.
ambiguous
D.
dubious
Answer: _________
Question 200:
Some Streams work with input, and some with output
A.
True
B.
False
Answer: _________
Question 201:
If you design a class that needs special initialization tasks, you will want to design a(n) _____
A.
housekeeping routine
B.
initializer
C.
constructor
D.
compiler
Answer: _________
Question 202:
Which type of statement does not occur in computer programs?
A.
sequence
B.
loop
C.
denial
D.
selection
Answer: _________
Question 203:
The newline character is always included between
A.
pair of parentheses
B.
pair of curly braces
C.
control string
D.
&
Answer: _________
Question 204:
To be called object-oriented, a programming language must allow
A.
functions that return only a single value
B.
#include files
C.
inheritance
D.
All of the above
Answer: _________
Question 205:
A function that returns no values to the program that calls it is _____
A.
not allowed in C++
B.
type void
C.
type empty
D.
type barren
Answer: _________
Question 206:
The keyword used to define a structure is _____
A.
stru
B.
stt
C.
struct
D.
structure
Answer: _________
Question 207:
If container classes are carefully constructed, then these tools are available to work with structures that are not ______
A.
valid without container classes
B.
programmer-defined
C.
type-specific
D.
public
Answer: _________
Question 208:
Header files often have the file extension _____
A.
.H
B.
.HE
C.
.HEA
D.
.HEAD
Answer: _________
Question 209:
A class named Student must have a constructor whose name is
A.
Student
B.
~Student
C.
constructor
D.
any legal C++ name
E.
student
F.
~student
G.
constructor
H.
any legal C++ name.
Answer: _________
Question 210:
To write data that contains variables of type float, to an object of type ofstream, you should use
A.
the insertion operator
B.
seekg()
C.
writeQ
D.
put()
Answer: _________
Question 211:
The main difference in operation between an 'if statement and a 'while' statement is
A.
the 'while' loop body is executed
B.
the body of the 'while' statement may be executed many times, the body of the 'if statements only once
C.
the conditional expression following the keyboard is evaluated differently
D.
All of the above
Answer: _________
Question 212:
If a class object is thrown with a throw statement, then a subsequent catch block has a usable match if the type of the catch argument is_________
A.
a parent class of the thrown class
B.
a child class of the thrown class
C.
either (a) or (b)
D.
neither (a) nor (b)
Answer: _________
Question 213:
The weakest form of cohesion is
A.
coincidental
B.
functional
C.
logical
D.
communicational
Answer: _________
Question 214:
The 'continue' statement is used to
A.
permit two different expressions to appear in situations where only one expression would ordinarily be used
B.
terminate loops or to exit from a switch
C.
alter the normal sequence of program execution by transferring control to some other part of the program
D.
All of the above
Answer: _________
Question 215:
The 'break' statement is used to exist from
A.
a do loop
B.
a for loop
C.
a switch statement
D.
All of the above
Answer: _________
Question 216:
A constructor initialization list is preceded by
A.
One semicolon
B.
One colon
C.
Two colons
D.
One space
Answer: _________
Question 217:
In C++, a function contained within a class is called
A.
a member function
B.
an operator
C.
a class function
D.
a method
Answer: _________
Question 218:
You can use C++ as a procedural, as well as an object-oriented, language
A.
True
B.
False
Answer: _________
Question 219:
A default catch block catches
A.
all thrown objects
B.
no thrown objects
C.
any thrown object that has not been caught by an earlier catch block
D.
all thrown objects that have been caught by an earlier catch block
Answer: _________
Question 220:
Adding a derived class to a base class requires fundamental changes to the base class
A.
True
B.
False
Answer: _________
Question 221:
Format flags may be combined using
A.
the bitwise OR operator (|)
B.
the logical OR operator (||)
C.
the bitwise AND operator (&)
D.
the logical AND operator (&&)
Answer: _________
Question 222:
To expose a data member to the program, you must declare the data member in the _____ section of the class
A.
common
B.
exposed
C.
public
D.
unrestricted
Answer: _________
Question 223:
Evaluate the following expression: 3 >6&&7>4
A.
True
B.
False
Answer: _________
Question 224:
Which of the following are valid characters for a numeric literal constant?
A.
a comma
B.
a dollar sign ($)
C.
a percent sign (%)
D.
a space
E.
a decimal point
F.
the letter e
G.
a minus sign
H.
a plus sign
Answer: _________
Question 225:
A function that changes the state of the cout object is called a(n) _____
A.
member
B.
adjuster
C.
manipulator
D.
operator
Answer: _________
Question 226:
A C++ program contains a function with the header int function(double d, char c). Which of the following function headers could be used within the same program?
A.
char function(double d, char c)
B.
int function(int d, char c)
C.
both (a) and (b)
D.
neither (a) nor (b)
Answer: _________
Question 227:
The feature that allows you to use the same function name for separate functions that have different argument lists is called _____
A.
overriding
B.
overloading
C.
constructing
D.
destructing
Answer: _________
Question 228:
Which of the following are valid characters constants?
A.
'
'
B.
'\'
C.
'x00'
D.
All of the above
Answer: _________
Question 229:
With a template class, _____ type is generic
A.
no
B.
exactly one
C.
at least one
D.
at most one
Answer: _________
Question 230:
If you want to use a class to define objects in many different programs, you should define the class in a C++ _____ file
A.
header
B.
program
C.
source
D.
text
Answer: _________
Question 231:
Functions that returns information about an object's state can be classified as ________
A.
inspector functions
B.
mutator functions
C.
auxiliary functions
D.
manager functions
Answer: _________
Question 232:
An auxiliary function _____
A.
return information about data members
B.
changes the state of data members
C.
performs an action or service
D.
creates and destroys objects
Answer: _________
Question 233:
To create and execute a C++ program, you need to have access to
A.
a C++ compiler
B.
a C++ translator
C.
an object code editor
D.
a text editor
Answer: _________
Question 234:
If you omit any constructor argument when you instantiate an object, you must use default values______
A.
for all parameters to the constructor
B.
for all parameters to the right of the argument
C.
for all parameters to the left of the argument
D.
for no other parameters
Answer: _________
Question 235:
Many programmers separate a class into two files: _____
A.
one for the declarations and one for the implementations
B.
one for the void functions and one for the other functions
C.
one for the public data and one for the private data
D.
one for the primary functions and one for the auxiliary functions
Answer: _________
Question 236:
Files whose names end in .h are called _____ files
A.
handy
B.
header
C.
helper
D.
helping
Answer: _________
Question 237:
Which of the following is NOT included in the header of a function?
A.
the type of variable returned by the function to the function that calls it
B.
the name of the program or function that calls the function
C.
the name of the function
D.
the types and names of any variables that will be passed to the function
Answer: _________
Question 238:
If you want only one memory location to be reserved for a class variable, no matter how many objects are instantiated, you should declare the variable as________
A.
dynamic
B.
unary
C.
static
D.
volatile
Answer: _________
Question 239:
The logical NOT operator represented by is a
A.
unary operator
B.
binary operator
C.
ternary operator
D.
octal operator
Answer: _________
Question 240:
When variables refer to attributes of an entity (such as name, address, and phone number of a person), those attributes form a _____
A.
file
B.
record
C.
field
D.
program
Answer: _________
Question 241:
A function's single most important role is to
A.
give a name to a block of code
B.
reduce program size
C.
accept arguments and provide a return value
D.
help organize a program into conceptual units
Answer: _________
Question 242:
The delete operator returns ______ to the operating system
A.
memory that is no longer needed
B.
void
C.
recycle bin
D.
None of the above
Answer: _________
Question 243:
The major advantage of data hiding is that _____
A.
your programs can include more data
B.
you no longer need functions
C.
no one can ever use your data
D.
your data will be used correctly
Answer: _________
Question 244:
The letter V is a _____
A.
character literal constant
B.
numeric literal constant
C.
string literal constant
D.
variable
Answer: _________
Question 245:
Assuming the following three operators appear in an expression (without parentheses), which of the operators will be performed first?
A.
&&
B.
!
C.
||
D.
source code
Answer: _________
Question 246:
The code that you enter into a C++ program is called _____
A.
console code
B.
object code
C.
project code
D.
source code
Answer: _________
Question 247:
If a base class member is private, then
A.
if a derived class uses the public access specifier, the data member becomes public
B.
if a derived class uses the protected access specifier, the data member becomes protected
C.
both (a) and (b)
D.
neither (a) nor (b)
Answer: _________
Question 248:
Which of the following instructions tells C++ to merge the source code from the iostream.h file into the current file?
A.
#include <iostream.h>
B.
#include iostream.h
C.
/#include <iostream.h>
D.
#merge iostream.h
Answer: _________
Question 249:
The two parts of a function are the
A.
header and footer
B.
declarations and statements
C.
legs and feet
D.
header and body
Answer: _________
Question 250:
The general principle underlying object-oriented error handling is that a called function should __________
A.
neither check for, nor handle errors
B.
check for errors but not be required to handle any detected
C.
handle errors, but not check for them
D.
both check for and handle errors
Answer: _________
Question 251:
Reference variables and const class member
A.
must be assigned values in any derived class
B.
must never be initialized in a base class
C.
must be initialized, rather than assigned values
D.
must not exit if a class is to be a base class
Answer: _________
Question 252:
The actual arguments cannot he
A.
a constant or a variable
B.
of a different type from the corresponding formal arguments
C.
other functions
D.
expressions
Answer: _________
Question 253:
A translator that notes whether you have used a language correctly may be called a _____
A.
theasurus
B.
compiler
C.
coder
D.
decoder
Answer: _________
Question 254:
The feature in object-oriented programming that allows the same operation to be carried out differently, depending on the object, is_____
A.
inheritance
B.
polymorphism
C.
overfunctioning
D.
overriding
Answer: _________
Question 255:
When an argument is passed by reference,
A.
a variable is created in the function to hold the argument's value
B.
the function cannot access the argument's value
C.
a temporary variable is created in the calling program to hold the argument's value
D.
the function accesses the argument's original value in the calling program
Answer: _________
Question 256:
The process of extracting the relevant attributes of an object is known as
A.
polymorphism
B.
inheritance
C.
abstraction
D.
data hiding
Answer: _________
Question 257:
You must provide a constructor for a derived class
A.
always
B.
if the base class constructor required arguments
C.
if the base class constructor does not required arguments
D.
never
Answer: _________
Question 258:
If you want to override constructor default values for an object you are instantiating, you must also override
A.
all other parameters to that constructor
B.
all parameters to the left of that value
C.
all parameters to the right of that value
D.
no other parameters to that constructor
E.
all other parameters to that constructor
F.
all parameters to the left of that value
G.
all parameters to the right of that value
H.
no other parameters to that constructor
Answer: _________
Question 259:
To use one of the C++ built-in mathematical functions, you must include the _____ header file in your program
A.
calculation.h
B.
compute.h
C.
expression.h
D.
math.h
Answer: _________
Question 260:
Errors in a program are called
A.
accidents
B.
annoyances
C.
bugs
D.
mistakes
Answer: _________
Question 261:
You define a structure type globally because
A.
you save many lines of code by not rewriting an identical structure definition in each function that uses it
B.
you will never change its definition
C.
it is required in C++
D.
all of the above
Answer: _________
Question 262:
The standard output stream, which refers to the computer screen, is called
A.
cin
B.
cout
C.
stin
D.
stout
Answer: _________
Question 263:
Which of the following operators is the equality operator?
A.
!=
B.
=
C.
==
D.
→›
Answer: _________
Question 264:
In C++, you use _____ to perform standard input and output operations
A.
characters
B.
sequences
C.
streams
D.
tests
Answer: _________
Question 265:
Values that are used to end loops are referred to as _____ values
A.
end
B.
finish
C.
sentinel
D.
stop
Answer: _________
Question 266:
Which of the following flowchart symbols represents the if selection structure?
A.
diamond
B.
hexagon
C.
oval
D.
parallelogram
Answer: _________
Question 267:
Two or more arrays whose elements are related by their position (subscript) in the arrays are called _____ arrays
A.
horizontal
B.
paired
C.
parallel
D.
related
Answer: _________
Question 268:
The body of a C++ function is surrounded by _____
A.
parentheses
B.
angle brackets
C.
curly brackets
D.
square brackets
Answer: _________
Question 269:
The #ifndef directive tests to see whether ________
A.
a class has been defined
B.
a variable has been given a value
C.
a class has no variable definitions
D.
any objects of the class have been instantiated
Answer: _________
Question 270:
The generic type in a template function
A.
must be T
B.
can be T
C.
cannot be T for functions you create, but may be for C++'s built-in functions
D.
cannot be T
Answer: _________
Question 271:
When a child class function is called, the compiler looks first for a matching function name in the _____
A.
class of the object using the function name
B.
immediate ancestor class
C.
base class
D.
descendant class
Answer: _________
Question 272:
A function that is called automatically each time an object is destroyed is a
A.
constructor
B.
destructor
C.
destroyer
D.
terminator
E.
constructor
F.
destructor
G.
destroyer
H.
terminator
Answer: _________
Question 273:
If you create an instantiation of a class template with an int, and then create a second instantiation with a double, then
A.
you must precede each function call with the word int or double
B.
once a function is used as one type, it becomes unavailable for use with the other type
C.
there is no difference in the procedure to call a member function
D.
you cannot perform this operation in C++
Answer: _________
Question 274:
The step-by-step instructions that solve a problem are called _____
A.
an algorithm
B.
a list
C.
a plan
D.
a sequential structure
Answer: _________
Question 275:
The type to be used in an instantiation of a class template follows ________
A.
the generic class name
B.
the keyword template
C.
the keyword class
D.
the template definition
Answer: _________
Question 276:
When you pass a variable _____, C++ passes only the contents of the variable to the receiving function
A.
by reference
B.
by value
C.
globally
D.
locally
Answer: _________
Question 277:
Object is to class as _____
A.
library is to book
B.
mother is to daughter
C.
Plato is to philosopher
D.
president is to Lincoln
Answer: _________
Question 278:
A derived class may also be called a
A.
subclass
B.
super class
C.
parent class
D.
base class
E.
subclass
F.
super class
G.
parent class
H.
derived class
Answer: _________
Question 279:
The C++ keyword for declaring a variable that contains a decimal point is _____
A.
dec
B.
decimal
C.
float
D.
floater
Answer: _________
Question 280:
A program can directly access the _____ members of a class
A.
hidden
B.
private
C.
public
D.
both (b) and (c)
Answer: _________
Question 281:
Any output manipulator function you create _____
A.
should take as an argument an instance of ostream as a reference
B.
should return void
C.
must be a member function of the ostream class
D.
must inherit ostream
Answer: _________
Question 282:
To pass an array by reference, you
A.
must include the address-of (&) operator before the array's name
B.
must include the number symbol (#) before the array's name
C.
do not have to do anything because arrays are automatically passed by reference
D.
None of the above
Answer: _________
Question 283:
The instructions you enter into the computer are called the _____
A.
edited code
B.
machine code
C.
object code
D.
source code
Answer: _________
Question 284:
The String data type is an extension of the _____ data type
A.
Character
B.
Double
C.
Letter
D.
Long
Answer: _________
Question 285:
An advantage of using local variables is that _____
A.
they are known to all functions in the file
B.
names used in one function do not affect data stored in variables with the same names in other functions
C.
values given to local variables are retained when those parameters go out of scope
D.
the program does not become "crowded" with too many variable names
Answer: _________
Question 286:
When the compiler cannot differentiate between two overloaded constructors, they are called______
A.
overloaded
B.
destructed
C.
ambiguous
D.
dubious
Answer: _________
Question 287:
A function argument is
A.
a variable in the function that receives a value from the calling program
B.
a way that functions resist accepting the calling program's values
C.
a value sent to the function by the calling program
D.
a value returned by the function to the calling program
Answer: _________
Question 288:
Passing a variable pointer as a constant _____
A.
protects the contents pointed to by the pointer from change
B.
eliminates the need to name the pointer in the function
C.
eliminates the need to give the pointer a type in the function
D.
causes a copy of the pointer to be produced in the function
Answer: _________
Question 289:
Recursive Functions
A.
easier to code
B.
executable faster than iterative ones
C.
takes less main storage space
D.
necessary to solve a certain class of problems
Answer: _________
Question 290:
The purpose of a conditional operator is to
A.
select one of the two values
B.
select the highest of the two values
C.
select one of the two values depending on a condition
D.
select the more equal of the two values
Answer: _________
Question 291:
Which of the following, if any, are valid names for variables?
A.
amt.Sold
B.
amt-Sold
C.
amt_Sold
D.
98Sold
E.
class
F.
friend
G.
#OnHand
H.
void
Answer: _________
Question 292:
Assume you want to compare the character stored in the initial variable to the letter a. Which of the following conditions should you use in the if statement? (Be sure the condition will handle a or A.)
A.
(initial = 'a' or 'A')
B.
(initial == 'a' or 'A')
C.
(toupper(initial) = 'A')
D.
(toupper(initial) == 'A')
Answer: _________
Question 293:
You can override a class's inherited access to make an individual member's access more ______
A.
liberal
B.
conservative
C.
either (a) or (b)
D.
neither (a) nor (b)
Answer: _________
Question 294:
A class hierarchy
A.
describes "is a kind of" relationships
B.
describes "has a" relationships
C.
shows the same relationships as an organization chart
D.
shows the same relationships as a family tree
Answer: _________
Question 295:
The measure of how well the operations in a function relate to one another is _____
A.
coupling
B.
cohesion
C.
adhesion
D.
conversion
Answer: _________
Question 296:
An unsigned double type of data
A.
can have only positive values
B.
does not exist
C.
is always less than 1010
D.
can have only negative values
Answer: _________
Question 297:
The extraction operator >> is a(n) _____
A.
overloaded function
B.
C++ class
C.
C++ object
D.
static reference variables
Answer: _________
Question 298:
Modules in C++ programs are
A.
functions
B.
procedures
C.
subroutines
D.
miniprograms
Answer: _________
Question 299:
The return type for all destructors is
A.
the class
B.
void
C.
the same as the first data in the class
D.
None
Answer: _________
Question 300:
If an exception is thrown and no catch block matches the type of the thrown parameter, then _____
A.
the program terminates
B.
the first catch block is executed
C.
the last catch block is executed
D.
the program proceeds with the code following the catch blocks
Answer: _________
Question 301:
The comma operator (,) is used to
A.
permit two different expressions to appear in situations where only one expression would ordinarily be used
B.
terminate loops or to exit from switch
C.
alter the normal sequence of program execution by transferring control to some other part of the program
D.
carry out a logical test and then take one of two possible actions, depending upon the outcome of the test
Answer: _________
Question 302:
Which of the following type casts will convert an Integer variable named amount to a Double type?
A.
(double) amount
B.
(int to double) amount
C.
int to double(amount)
D.
int (amount) to double
Answer: _________
Question 303:
The loosest type of coupling is
A.
data coupling
B.
control coupling
C.
external coupling
D.
pathological coupling
Answer: _________
Question 304:
Which of the following is a string literal constant?
A.
"Visual C++"
B.
"137.45"
C.
"A"
D.
"2,365"
Answer: _________
Question 305:
A child class _____ exist if there is no parent class
A.
must
B.
may
C.
cannot
D.
can
Answer: _________
Question 306:
Programmer-defined functions can be
A.
value-returning functions only
B.
void functions only
C.
either value-returning or void functions
D.
None of the above
Answer: _________
Question 307:
A class D can be derived from a class C, which is derived from a class B, which is derived from a class A
A.
True
B.
False
Answer: _________
Question 308:
To use the strcpy function, you must include the _____ header file in your program
A.
assign.h
B.
copy.h
C.
string.h
D.
strcopy.h
Answer: _________
Question 309:
The number of the relational operators in the C language is
A.
four
B.
six
C.
three
D.
one
Answer: _________
Question 310:
Which of the following tells C++ to display numbers with two decimal places?
A.
setdecimal(2)
B.
setiosflags(2)
C.
setiosflags(2.00)
D.
setprecision(2)
Answer: _________
Question 311:
We can output text to an object of class ofstream using the insertion operator « because
A.
the ofstream class is a stream
B.
the insertion operator works with all classes
C.
we are actually outputting to cout
D.
the insertion operator is overloaded in ofstream
Answer: _________
Question 312:
The operator that allocates new memory is _____
A.
allocate
B.
mem
C.
new
D.
next
Answer: _________
Question 313:
When you declare a pointer, you must give it a _____
A.
type
B.
type and name
C.
type, name and value
D.
name and value
Answer: _________
Question 314:
You typically initialize Short Integer, Integer and Long Integer variables to
A.
a space enclosed in double quotes
B.
a space enclosed in single quotes
C.
the letter O
D.
the number 0
Answer: _________
Question 315:
Assume that a variable will need to store only integers in the range of 1 through 20000. The most efficient data type for the variable is _____
A.
character
B.
float
C.
integer
D.
long integer
Answer: _________
Question 316:
Which of the following is true?
A.
iostream is derived from istream
B.
iostream is derived from ostream
C.
ostream is derived from iostream
D.
ostream is derived from istream
Answer: _________
Question 317:
Any #include files may contain
A.
constants
B.
variables
C.
functions
D.
All of the above
Answer: _________
Question 318:
When a break statement is used in a loop, the control skips the rest of the statements in the loop after it and jumps
A.
to the last lines in the program
B.
to the next statement written after the body of the loop
C.
to the first statement in the body of the loop
D.
All of the above
Answer: _________
Question 319:
The function that takes arguments to set the bits of count is _____
A.
setf()
B.
bitsef()
C.
ios()
D.
flag()
Answer: _________
Question 320:
When two types are used in a function template and one is labeled T, the other
A.
must also be named T
B.
must be named U
C.
can be any legal C++ identfier
D.
it is illegal to have two types
Answer: _________
Question 321:
The best-written classes have
A.
all functions private
B.
all data public
C.
no functions
D.
None of the above
Answer: _________
Question 322:
The base class for most stream classes is the _____ class
A.
ios
B.
out
C.
in
D.
app
Answer: _________
Question 323:
The most efficient data type for a variable that stores the number 4.6e20 is the _____ data type
A.
Character
B.
Double
C.
Float
D.
Long Integer
Answer: _________
Question 324:
Which of the following can be used to declare the main function?
A.
void main
B.
void Main()
C.
void main()
D.
main
Answer: _________
Question 325:
You _____ write your own container classes
A.
must
B.
may
C.
should not
D.
must not
Answer: _________
Question 326:
If an integer object is thrown with a throw statement, then a subsequent catch block has a usable match if the type of the catch argument is
A.
int
B.
double
C.
either (a) or (b)
D.
neither (a) nor (b)
Answer: _________
Question 327:
The highest level of cohesion is
A.
functional cohesion
B.
temporal cohesion
C.
logical cohesion
D.
sequential cohesion
Answer: _________
Question 328:
You separate a derived class name from its access specifier with
A.
a colon
B.
two colons
C.
at least one space
D.
a semicolon
Answer: _________
Question 329:
The last statement in a function is often a(n) _____
A.
return
B.
goodbye
C.
finish
D.
endfunction
Answer: _________
Question 330:
When the function int someFunction(char c) throw( ) is executed, _____
A.
it can throw anything
B.
it may throw an integer
C.
it may throw a character
D.
it may not throw anything
Answer: _________
Question 331:
The two statements that can be used to change the flow of control are
A.
if and switch
B.
if and while
C.
switch and do-while
D.
break and continue
Answer: _________
Question 332:
If p and q are assigned the values 2 and 3 respectively then the statement p = q++
A.
gives an error message
B.
assigns a value 4 to p
C.
assigns a value 3 to p
D.
assigns a value 5 to p
Answer: _________
Question 333:
Which of the following is the insertion operator?
A.
>>
B.
<<
C.
//
D.
/*
Answer: _________
Question 334:
If you want only one memory location to be reserved for a class variable, no matter how many objects are instantiated, you should declare the variable as
A.
static
B.
unary
C.
dynamic
D.
volatile
Answer: _________
Question 335:
To use a template class member function, use the ________ with the instantiation
A.
scope resolution operator
B.
dot operator
C.
class definition
D.
keyword template
Answer: _________
Question 336:
When a class is derived from another derived class, the newly derived class
A.
may have more liberal access to a base class member than its immediate predecessor
B.
may have the same type of access to a base class member as its immediate predecessor
C.
may have more limited access to a base class member than its immediate predecessor
D.
both (b) and (c)
Answer: _________
Question 337:
If you assign a default value to any variable in a function prototype's parameter list, then _____
A.
all other parameters in the function prototype must have default values
B.
all parameters to the right of that variable must have default values
C.
all parameters to the left of that variable must have default values
D.
no other parameters in that prototype can have default values
Answer: _________
Question 338:
The dot operator (or class member access operator) connects the following two entities (reading from left to right):
A.
a class member and a class object
B.
a class object and a class
C.
a class and a member of that class
D.
a class object and a member of that class
Answer: _________
Question 339:
One of the logical operators in the C language is represented by the symbol
A.
AND
B.
&&
C.
>=
D.
<=
Answer: _________
Question 340:
Which of the following tells C++ to display numbers in fixed notation?
A.
setiosflags(fixed)
B.
setiosflags(fixed: :is)
C.
setiosflags(ios, fixed)
D.
setiosflags(ios::fixed)
Answer: _________
Question 341:
The #include instruction is called a
A.
direction
B.
directive
C.
merge instruction
D.
statement
Answer: _________
Question 342:
Another drawback to returning an error code from a function is that any error code returned by the function
A.
must be of the same type as return type of the function
B.
must not be a character
C.
cannot be checked in a main() program
D.
can have multiple meanings
Answer: _________
Question 343:
Classes hold _____
A.
data
B.
methods
C.
both data and methods
D.
neither data nor methods
Answer: _________
Question 344:
In C++, the address operator is the following symbol _____
A.
>>
B.
&
C.
*
D.
!
Answer: _________
Question 345:
The function that takes arguments to set the bits of cout is _____
A.
setf()
B.
bitset()
C.
ios()
D.
flat()
Answer: _________
Question 346:
A default exception block must be placed _____
A.
first among the catch blocks
B.
last among the catch blocks
C.
globally, at the top of the file
D.
at the end of all code in the program
Answer: _________
Question 347:
Which of the following control structures is used in every program?
A.
repetition
B.
selection
C.
sequence
D.
switching
Answer: _________
Question 348:
In the C language, a string is assigned to the
A.
char type of variable
B.
string type of variable
C.
conversion specification %s
D.
All of the above
Answer: _________
Question 349:
The main() function is always
A.
a called function
B.
a calling function
C.
recursive function
D.
used at the end of the program
Answer: _________
Question 350:
Variables that are known only to the function in which they are declared are called _____ variables
A.
global
B.
local
C.
main
D.
separate
Answer: _________
Question 351:
In the expression p → val, p is a(n)
A.
address
B.
pointer
C.
structure
D.
header
Answer: _________
Question 352:
In a template function, _____ argument is generic, or parameterized
A.
no
B.
exactly one
C.
at least one
D.
more than one
Answer: _________
Question 353:
Object-oriented programmers primarily focus on _________
A.
procedures to be performed
B.
the step-by-step statements needed to solve a problem
C.
objects and the tasks that must be performed with those objects
D.
the physical orientation of objects within a program
Answer: _________
Question 354:
Which of the following is the inequality operator?
A.
!=
B.
=
C.
==
D.
→
Answer: _________
Question 355:
If a derived class uses the public access specifier, then _____
A.
public base class members remain public in the derived class
B.
protected base class members become public in the derived class
C.
both (a) and (b)
D.
neither (a) nor (b)
Answer: _________
Question 356:
The operator that releases previously allocated memory is _____
A.
release
B.
return
C.
delete
D.
destroy
Answer: _________
Question 357:
When a language has the capability to produce new data types, it is said to be
A.
reprehensible
B.
encapsulated
C.
overloaded
D.
extensible
Answer: _________
Question 358:
A compound statement does not consist of
A.
a single statement
B.
other compound statements
C.
expression statements
D.
control statements
Answer: _________
Question 359:
The preprocessor directive always starts with the symbol
A.
%
B.
&
C.
#
D.
""
Answer: _________
Question 360:
Which of the following statements is true?
A.
Data coupling is tighter than pathological coupling
B.
Common coupling is looser than data coupling
C.
Data-structured coupling is looser than control coupling
D.
Control coupling is looser than data coupling
Answer: _________
Question 361:
Evaluate the following expression: 7 >=3 + 4 || 6<4 && 2<5
A.
True
B.
False
Answer: _________
Question 362:
The data type listed at the beginning of a value-returning function's header indicates the type of data the function will _____
A.
return
B.
pass
C.
receive
D.
None of the above
Answer: _________
Question 363:
The code class Descendant : virtual public Ancestor indicates that
A.
the members of Ancestor will be included more than once in Descendant
B.
the members of Ancestor will be included only once in Descendant
C.
the members of Descendant will be included more than once in Ancestor
D.
the members of Descendant will be included only once in Ancestor
Answer: _________
Question 364:
Which of the following formulas can be used to generate random integers between 1 and 10?
A.
1 + rand() % (10 - 1 + 1)
B.
1 + (10 - 1 + 1) % rand()
C.
10 + rand() % (10 - 1 + 1)
D.
10 + rand() % (10 + 1)
Answer: _________
Question 365:
Format flags may be combined using the _____
A.
bitwise OR operator(|)
B.
logical OR operator (||)
C.
bitwise AND operator (&)
D.
logical AND operator (&&)
Answer: _________
Question 366:
The arguments that determine the state of the cout object are called
A.
classes
B.
manipulators
C.
format flags or state flags
D.
state controllers
Answer: _________
Question 367:
If a class will serve as a base class, most often the base class data members are
A.
private
B.
protected
C.
public
D.
polymorphic
Answer: _________
Question 368:
You can use the C++ _____ function to assign a value to a String variable
A.
assign
B.
copy
C.
string
D.
strcopy
Answer: _________
Question 369:
A measure of the strength of the connection between two functions is
A.
cohesion
B.
coupling
C.
dependence
D.
subjection
Answer: _________
Question 370:
Catch blocks must _____
A.
appear in every object-oriented program
B.
appear within try blocks
C.
appear immediately after throw statements
D.
appear immediately after try blocks
Answer: _________
Question 371:
An exception specification begins with the keyword _____
A.
exception
B.
try
C.
throw
D.
catch
Answer: _________
Question 372:
You construct a class in two sections, known as the _____
A.
header and body
B.
type and parameters
C.
declaration and implementation
D.
pointer and variable
Answer: _________
Question 373:
It is sometimes useful to specify a class from which no objects will ever be created
A.
True
B.
False
Answer: _________
Question 374:
The statement i* = 3 is equivalent to
A.
i = 3*
B.
i = 3
C.
i* = 3
D.
i = i * 3
Answer: _________
Question 375:
The complement operator is represented by the symbol
A.
~
B.
^
C.
i
D.
<
Answer: _________
Question 376:
One of the relational operators in the C language is
A.
!=
B.
&&
C.
!
D.
#
Answer: _________
Question 377:
Within a program, you can instantiate ________that have a class template type
A.
classes
B.
functions
C.
parameters
D.
objects
Answer: _________
Question 378:
The rules to any programming language are its _______
A.
syntax
B.
interpretation
C.
logic
D.
customs
Answer: _________
Question 379:
Which of the following backslash codes used for bell?
A.
x08
B.
a
C.
s
Answer: _________
Question 380:
If no exception is thrown ________
A.
a catch block will cause an error
B.
the first catch block coded will execute
C.
the last catch block coded with execute
D.
any catch blocks coded with be bypassed
Answer: _________
Question 381:
A program that predicts the exact sequence in which events will take place is said to be ________
A.
compiled
B.
interpreted
C.
procedural
D.
object-oriented
Answer: _________
Question 382:
A blueprint for creating an object in C++ is called _____
A.
a class
B.
an instance
C.
a map
D.
a pattern
Answer: _________
Question 383:
The prototype for a derived class constructor may include arguments for
A.
data members of the derived class
B.
data members of the base class
C.
both (a) and (b)
D.
neither (a) nor (b)
Answer: _________
Question 384:
Overloading involves writing two or more functions with ________
A.
different names and different argument lists
B.
different names and the same argument list
C.
the same name and different argument lists
D.
the same name and the same argument list
Answer: _________
Question 385:
You ___________ overload function templates
A.
may, as long as each version has the same arguments
B.
may, as long as each version has different arguments
C.
must
D.
must not
Answer: _________
Question 386:
You typically initialize Character variables to _____
A.
a space enclosed in double quotes
B.
a space enclosed in single quotes
C.
the letter O
D.
the number 0
Answer: _________
Question 387:
One way pointers are useful is to refer to a memory address that has no _____
A.
name
B.
constant
C.
location
D.
field
Answer: _________
Question 388:
A member function uses the correct object when you call it because
A.
a copy of the object is passed to the function
B.
the address of the object is passed to the function
C.
the address of the function is passed to another function
D.
the address of the object is returned from the function
Answer: _________
Question 389:
Two access specifiers in C++ are
A.
public and private
B.
int and double
C.
formal and informal
D.
void and free
Answer: _________
Question 390:
Sending a copy of data to a program module is called _______
A.
passing a value
B.
making a reference
C.
recursion
D.
setting a condition
Answer: _________
Question 391:
Of the three ways to pass arguments to functions, only passing by _____ and passing by _____ allow the function to modify the argument in the calling program
A.
reference, pointer
B.
array, location
C.
array, pointer
D.
None of the above
Answer: _________
Question 392:
To use either an input or output file, the program must include the _____ header file
A.
filestream.h
B.
fstream.h
C.
instream.h
D.
inoutstream.h
Answer: _________
Question 393:
A widget is to the blueprint for a widget as an object is to
A.
a member function
B.
a class
C.
an operator
D.
a data item
Answer: _________
Question 394:
C++ allows you to define the same functions more than once in the same program _____
A.
if the definitions are identical
B.
if the definitions are included in two separate #include files
C.
if the definitions are located in a single #include file that is included more than once
D.
C++ does not allow you to define the same functions more than once in the same program
Answer: _________
Question 395:
Which of the following assigns the number 5 to the area variable?
A.
area 1 = 5
B.
area = 5
C.
area == 5
D.
area → 5
Answer: _________
Question 396:
A base class may also be called a
A.
child class
B.
subclass
C.
derived class
D.
parent class
Answer: _________
Question 397:
The _____ mode tells C++ to open a file for input
A.
add::ios
B.
in::file
C.
ios::app
D.
ios::in
Answer: _________
Question 398:
Using the wardrobe structure within the ShopList structure is an example of a good programming principle, known as _____
A.
reusability
B.
polymorphism
C.
redundancy
D.
recursion
Answer: _________
Question 399:
When you omit parameters from a function call, values can be provided by
A.
formal parameters
B.
reference parameters
C.
overloaded parameters
D.
default parameters
Answer: _________
Question 400:
The time and memory involved in calling a function represent the function's _____
A.
prototype
B.
overhead
C.
cost
D.
burden
Answer: _________
Question 401:
Which function is most likely to have procedural cohesion?
A.
main()
B.
findSquareRoot()
C.
getSaleSubtractDiscountAddTax()
D.
openFiles()
Answer: _________
Question 402:
A pointer is
A.
the address of a variable
B.
an indication of the variable to be accessed next
C.
a variable for storing addresses
D.
the data type of an address variable
Answer: _________
Question 403:
The instruction "If it's raining outside, then take an umbrella to work" is an example of the _____ structure
A.
control
B.
repetition
C.
selection
D.
sequence
Answer: _________
Question 404:
The >> (extraction) operator stops reading characters from the keyboard as soon as the user _____
A.
presses the Enter key
B.
types a character that is inappropriate for the variable's data type
C.
both (a) and (b)
D.
neither (a) nor (b)
Answer: _________
Question 405:
In the statement template <class T>,
A.
T is a class
B.
T is a scalar variable
C.
either (a) or (b)
D.
neither (a) nor (b)
Answer: _________
Question 406:
The null character is represented by
A.
x00
B.
o
Answer: _________
Question 407:
The break statement is
A.
a preprocessor directive
B.
an operator in the C++ language
C.
a keyword in the C++ language
D.
switch in the C++ language
Answer: _________
Question 408:
A comment
A.
is a note that can be put into the source code
B.
is ignored by the compiler
C.
starts with the /* character pair
D.
All of the above
Answer: _________
Question 409:
Which of the following is(are) valid identifier(s)?
A.
record_1
B.
1 record
C.
return
D.
$tax
Answer: _________
Question 410:
The functions go in the _____ section of a class definition
A.
declaration
B.
implementation
C.
prototype
D.
functioning
Answer: _________
Question 411:
You can throw _____
A.
a scalar variable
B.
a constant
C.
a programmer-defined class object
D.
any of these
Answer: _________
Question 412:
You invoke a function with a function
A.
call
B.
declaration
C.
definition
D.
prototype
Answer: _________
Question 413:
Which is a good guideline for creating function names?
A.
Use all lowercase letters to identify the functions as C++ functions
B.
Use long names to reduce the likelihood of creating a duplicate function name
C.
Use abbreviations as much as possible to save both keystrokes and memory
D.
Avoid the use of digits because they are easily confused with letters
Answer: _________
Question 414:
Reserving memory during program execution is known as reserving it
A.
dynamically
B.
statically
C.
functionally
D.
powerfully
Answer: _________
Question 415:
"Rohan Motors" is a _____
A.
character literal constant
B.
numeric literal constant
C.
string literal constant
D.
variable
Answer: _________
Question 416:
A programming structure that contains data and a pointer to the next object is a
A.
template
B.
class
C.
pointer class
D.
linked list
Answer: _________
Question 417:
A variable declared in a function is called a(n) _____ variable
A.
area
B.
global
C.
local
D.
reference
Answer: _________
Question 418:
Variable names known only to the procedure in which they are declared are ________
A.
local
B.
global
C.
recent
D.
internal
Answer: _________
Question 419:
Whis is true?
A.
A derived class may have more than one base class
B.
A base class may have more than one derived class
C.
both (a) and (b)
D.
neither (a) nor (b)
Answer: _________
Question 420:
The keyword used to define a structure is
A.
stru
B.
stt
C.
struct
D.
unlimited
Answer: _________
Question 421:
If you omit any constructor argument when you instantiate an object, you must use default values
A.
for all parameters to the constructor
B.
for all parameters to the right of the argument
C.
for all parameters to the left of the argument
D.
for no other parameters
Answer: _________
Question 422:
The C++ expression p → val means the same thing as
A.
*p.val
B.
*(p.val)
C.
(*p).vai
D.
p.val
Answer: _________
Question 423:
Which of the following tells C++ to display numbers with zero decimal places?
A.
setiosflags(0)
B.
setiosflags(zero)
C.
setprecision(0)
D.
setprecision(zero)
Answer: _________
Question 424:
Code that has already been tested is said to be _____
A.
inherited
B.
reusable
C.
reliable
D.
polymorphic
Answer: _________
Question 425:
If no constructors can specified for a derived class, objects of the derived class will use the constructors in the base class
A.
True
B.
False
Answer: _________
Question 426:
The get() function returns _____
A.
a character
B.
void
C.
a reference to the object that invoked it
D.
a copy of the object that invoked it
Answer: _________
Question 427:
The most efficient data type for a variable that the number 20000 is the _____ data type
A.
Character
B.
Double
C.
Float
D.
Long Integer
Answer: _________
Question 428:
An expression contains relational, assignment and arithmetic operators. In the absence of parentheses, the order of evaluation will be
A.
assignment, relational, arithmetic
B.
arithmetic, relational, assignment
C.
relational, arithmetic, assignment
D.
assignment, arithmetic, relational
Answer: _________
Question 429:
The keyword virtual indicates that
A.
a derived class has public access to a base class
B.
more than one base class exists
C.
a base class should be used only once in inheritance
D.
a derived class should have more than one base class constructed
Answer: _________
Question 430:
Variables that are declared in a block are known as _____ variables to that block
A.
confined
B.
local
C.
global
D.
immediate
Answer: _________
Question 431:
The pow and sqrt functions return a(n) _____ type number
A.
double
B.
float
C.
integer
D.
long
Answer: _________
Question 432:
Declaring variables is advantageous because it
A.
avoids errors from misspelled variable names
B.
helps the linker work efficiently
C.
simplifies the writing of very short programs
D.
All of the above
Answer: _________
Question 433:
The generic name used for unexpected errors that occur during the execution of a program is
A.
infractions
B.
exceptions
C.
deviations
D.
anomalies
Answer: _________
Question 434:
You add the desired type to a specific template class instantiation by placing the type's name ______
A.
between angle brackets
B.
in parentheses
C.
on a line by itself
D.
immediately prior to the class name
Answer: _________
Question 435:
The switch variable can be of
A.
int type only
B.
char type only
C.
both int as well as char type
D.
float type only
Answer: _________
Question 436:
Reference variables and const class members _____
A.
must be assigned values in any derived class
B.
must never be initialized in a base class
C.
must be initialized, rather than assigned values
D.
must not exist if a class is to be a base class
Answer: _________
Question 437:
The best form of coupling is _____
A.
complete
B.
tight
C.
loose
D.
free
Answer: _________
Question 438:
Paying attention to the important properties while ignoring inessential details is known as________
A.
selectiveness
B.
polymorphism
C.
abstraction
D.
summarizing
Answer: _________
Question 439:
What does C++ append to the end of a string literal constant?
A.
a space
B.
a number sign (#)
C.
an asterisk (*)
D.
a null character
Answer: _________
Question 440:
An array name is a _____
A.
subscript
B.
formal parameter
C.
memory address
D.
prototype
Answer: _________
Question 441:
To enter a comment in a C++ program, you begin the comment with _____
A.
**
B.
&&
C.
\
D.
@
Answer: _________
Question 442:
Which of the following is(are) invalid string constant(s)?
A.
"7.15 pm"
B.
"i like e"
C.
"7.3el2"
D.
"1234el2"
Answer: _________
Question 443:
You define a structure type globally because _____
A.
you save many lines of code by not rewriting an identical structure definition in each function that uses it
B.
you will never change its definition
C.
it is required in C++
D.
All of the above
Answer: _________
Question 444:
Overloaded functions are required to
A.
have the same return type
B.
have the same number of parameters
C.
perform the same basic functions
D.
None of the above
Answer: _________
Question 445:
Redirection redirects
A.
a stream from a file to the screen
B.
a file from a device to a stream
C.
a device from the screen to a file
D.
the screen from a device to a stream
Answer: _________
Question 446:
You mark the beginning of a function's block of code with the _____
A.
/
B.
*
C.
{
D.
}
Answer: _________
Question 447:
Which of the following is the fourth problem-solving step?
A.
analyze the problem
B.
evaluate and modify (if necessary) the program
C.
code the algorithm
D.
plan the algorithm
Answer: _________
Question 448:
Within parentheses, catch blocks can have _____
A.
no arguments
B.
one argument
C.
two arguments
D.
as many arguments as necessary
Answer: _________
Question 449:
The while loop is referred to as a(n) _____ loop because the loop condition is tested at the beginning of the loop
A.
beginning
B.
initial
C.
pretest
D.
priming
Answer: _________
Question 450:
The word case used in the switch statement represents a
A.
function in the C++ language
B.
data type in the C++ language
C.
keyword in the C++ language
D.
global variable in the C++ language
Answer: _________
Question 451:
Function templates _____________
A.
must have exactly one parameter
B.
may have more than one parameter as long as they are of the same type
C.
may have more than one parameter of any type
D.
may not have parameters
Answer: _________
Question 452:
Private data can be accessed by
A.
class member functions
B.
functions in derived classes
C.
both (a) and (b)
D.
neither (a) nor (b)
Answer: _________
Question 453:
The store of memory available to programs is the _____
A.
store
B.
stack
C.
pile
D.
heap
Answer: _________
Question 454:
The most common operation used in constructors is _____
A.
addition
B.
overloading
C.
assignment
D.
polymorphism
Answer: _________
Question 455:
When a function performs tasks based on a decision, it has _____
A.
functional cohesion
B.
coincidental cohesion
C.
logical cohesion
D.
no cohesion
Answer: _________
Question 456:
A default constructor _____
A.
takes no arguments
B.
has default values for all its arguments
C.
either (a) or (b)
D.
neither (a) nor (b)
Answer: _________
Question 457:
The number 125.35 is a _____
A.
character literal constant
B.
numeric literal constant
C.
string literal constant
D.
variable
Answer: _________
Question 458:
When a class serves as a base class to others, _____
A.
all of its members are inherited
B.
all of its members are inherited, except for any private members
C.
all of its members are inherited, except for any protected members
D.
None of its members is inherited unless specifically "listed
Answer: _________
Question 459:
Storing a class definition in a separate file is an example of
A.
polymorphism
B.
name mangling
C.
implementation hiding
D.
inheritance
Answer: _________
Question 460:
A class named student must have a constructor whose name is
A.
Student
B.
~Student
C.
constructor
D.
any legal C++ name
E.
student
F.
~student
G.
constructor
H.
any legal C++ name.
Answer: _________
Question 461:
It is illegal to make objects of one class members of another class
A.
True
B.
False
Answer: _________
Question 462:
The following statement where T is true and F is false T&&T||F&&T
A.
is true
B.
is false
C.
is wrong
D.
not applicable in C language
Answer: _________
Question 463:
A program will have one function prototype for each function defined in the programmer-defined section of the program. (Assume that the programmer-defined section is located below the main function.)
A.
True
B.
False
Answer: _________
Question 464:
The standard input stream, which refers to the keyboard, is called
A.
cin
B.
cout
C.
stin
D.
stout
Answer: _________
Question 465:
If the code and fee arrays are parallel, the fee that corresponds to the code stored in the code[3] element is located in the _____ element
A.
code[2]
B.
code[3]
C.
fee[2]
D.
fee[3]
Answer: _________
Question 466:
Access specifiers are followed by
A.
a comma
B.
a semicolon
C.
a colon
D.
two colons
Answer: _________
Question 467:
Elements in an array are identified by a unique _____
A.
data type
B.
order
C.
subscript
D.
symbol
Answer: _________
Question 468:
To include the double quotes as part of the control string we use the symbol
A.
%"
B.
""
C.
"
D.
#
Answer: _________
Question 469:
Which of the following statements declares a one-dimensional Character array named item that consists of five elements?
A.
char item[0 to 4] = ""
B.
char item[0 to 5] = ""
C.
char item[4] = ""
D.
char item[5] = ""
Answer: _________
Question 470:
If you declare two objects as Customer firstCust, secondCust
which of the following must be true?
A.
Each object's nonstatic data members will be stored in the same memory location
B.
Each object will be stored in the same memory location
C.
Each object will have a unique memory address
D.
You cannot declare two objects of the same class
E.
Each object will store a separate copy of any static member data
F.
Each object will store a separate copy of any member functions
G.
Each object will store a separate copy of any nonstatic data members
H.
You cannot declare two objects of the same class
Answer: _________
Question 471:
Which of the following statements will display the word "Hello" on the computer screen?
A.
cin << "Hello"
B.
cin >> "Hello"
C.
cout << "Hello"
D.
cout >> "Hello"
Answer: _________
Question 472:
Which of the following will store the number 320000 as a Float number?
A.
counPop = (float) 3.2e5
B.
counPop = (float) 3.2e6
C.
counPop = (float) .32e5
D.
counPop = (float) .32e7
Answer: _________
Question 473:
Which of the following statements will assign the address of the age variable to the agePtr pointer?
A.
agePtr = &age
B.
agePtr = *age
C.
&agePtr = age
D.
*agePtr = age
Answer: _________
Question 474:
A variable w with a value 67 may be defined with _______
A.
int w = 67
B.
int w(67)
C.
int 67(w)
D.
both (a) and (b), but not (c)
Answer: _________
Question 475:
The statement int num[2][3]={{3,8,6}, {9,4,7}}
A.
assigns a value 4 to num[1][2]
B.
assigns a value 7 to num[1][2]
C.
assigns a value 8 to num[1][2]
D.
assigns a value 9 to num[1][2]
Answer: _________
Question 476:
One way in which a structure differs from an array is that _____
A.
a structure may have members of more than one type
B.
a structure must have members that
are all the same type
C.
art array may have members of more than one type
D.
there is no difference between a structure and an array
Answer: _________
Question 477:
The statement double val[15]={44.123456}
A.
assigns the value 44.123456 to all members of the array val
B.
assigns the value 44.123456 to val[0] and 0 to the rest of the members
C.
gives an error message
D.
assigns the value 44.12345 to val[1] and val[5]
Answer: _________
Question 478:
Which of the following C++ expressions will find the square root of the number 16?
A.
pow (16, 2)
B.
sqroot (16)
C.
sqrt (16, 2)
D.
sqrt (16)
Answer: _________
Question 479:
Which of the following statements declares a variable that can contain a decimal number?
A.
dec payRate
B.
dec hourlyPay
C.
float payRate
D.
float hourlyPay
Answer: _________
Question 480:
The statement int num[2][3] = {{1,2}, {3,4}, {5, 6}}
A.
assigns a value 2 to num[1][2]
B.
assigns a value 4 to num[1][2]
C.
gives an error message
D.
assigns a value 3 to num[1][2]
Answer: _________
Question 481:
A C++ statement must end in a
A.
: (column)
B.
, (comma)
C.
. (period)
D.
(semicolon)
Answer: _________
Question 482:
Which of the following statements uses the computer's clock to initialize the random number generator?
A.
srand(time)
B.
srand(time(NULL))
C.
time(srand)
D.
time(srand(NULL))
Answer: _________
Question 483:
Assume that a program creates and initializes a Short Integer variable named age and a pointer named agePtr, to which it assigns the address of the age variable. Which of the following statements will assign the number 21 to the age variable?
A.
age = 21
B.
*age = 21
C.
agePtr = 21
D.
*agePtr = 21
Answer: _________
Question 484:
The statement fwrite ( (char*)&objl, sizeof(objl) )
A.
writes the member functions of objl to fl
B.
writes the data in objl to fl
C.
writes the member functions and me data of objl to fl
D.
writes the address of objl to fl
Answer: _________
Question 485:
Which of the following statements allows the user to enter data at the keyboard?
A.
cin << currentPay
B.
cin >> currentPay
C.
cout << currentPay
D.
cout >> currentPay
Answer: _________
Question 486:
When you define an object that is a member of a class, such as Student Abby
_____
A.
a block of memory is set aside and all data members are assigned valid values
B.
a block of memory is set aside
C.
no memory is set aside until values are defined
D.
no memory is set aside, but valid values are assigned to data members
Answer: _________
Question 487:
A function that is prototyped as double calculate(int num)
may______
A.
receive an integer constant such as 5
B.
receive an integer variable
C.
either (a) or (b)
D.
neither (a) nor (b)
Answer: _________
Question 488:
The general form of do-while statement is
A.
do expression while statement
B.
do while expression
C.
do statement while (expression)
D.
do statement while statement
Answer: _________
Question 489:
Student senior()
is a(n)_________
A.
constructor call with no arguments
B.
object instantiation
C.
constructor call with all default arguments
D.
prototype for a function that returns a student object
Answer: _________
Question 490:
The statement int n[4] = {11, -13, 17, 105}
A.
assigns the value -13 to [2]
B.
assigns the value 17 to n[2]
C.
is wrong
it gives an error message
D.
assigns the value 18 to n[2]
Answer: _________
Question 491:
Which of the following while clause will stop the loop when the value in the age variable is less than the number 0?
A.
while age < 0
B.
while (age < 0)
C.
while age >= 0
D.
while (age >= 0)
Answer: _________
Question 492:
Which of the following calls a function named displayName, passing it no actual arguments?
A.
call displayName
B.
call displayName ()
C.
displayName
D.
displayName()
Answer: _________
Question 493:
The last statement in a value-returning function is always _____
A.
}
B.
result expression
C.
return
D.
return expression
Answer: _________
Question 494:
Which of the following declares and initializes an Integer variable named numltems?
A.
int numltems = 0
B.
int numltems = '0'
C.
integer numltems = 0
D.
numltems int = 0
Answer: _________
Question 495:
Which of the following statements will create and initialize a feelnfo array named fee?
A.
fee feeInfo = {{0}, {0}}
B.
fee as feeInfo = 0, 0
C.
feeInfo fee = 0, 0
D.
feeInfo fee = [{0}, {0}]
Answer: _________
Question 496:
You have assigned the address of Value to the pointer P, Which statement will display the value stored in Value?
A.
cout<<P
B.
cout<<*Value
C.
cout<<&P
D.
cout<<*P
Answer: _________
Question 497:
The use of the break statement in a switch statement is
A.
optional
B.
compulsory
C.
not allowed. It gives an error message
D.
to check an error
Answer: _________
Question 498:
The statement double total = 0.0
performs _____
A.
assignment
B.
initialization
C.
rationalization
D.
polymorphism
Answer: _________
Question 499:
Which of the following creates an animal object named dog?
A.
animal "dog"
B.
animal dog
C.
dog "animal"
D.
dog animal
Answer: _________
Question 500:
Which of the following statements creates a named constant called driverAge whose value is 16?
A.
const driverAge = 16
B.
const short driverAge = 16
C.
driverAge =16
D.
driverAge const =16
Answer: _________
Question 501:
Assume a program contains a void function named displayName, which requires no formal parameters. Which of the following is a correct function prototype for this function?
A.
displayName
B.
displayName(void)
C.
void displayName
D.
void displayName()
Answer: _________
Question 502:
The function whose prototype is Item getData(void)
returns _____
A.
the address of a structure
B.
a copy of a structure
C.
a pointer to a structure
D.
nothing
Answer: _________
Question 503:
The function whose prototype is void getData(Item *thing)
receives
A.
a pointer to a structure
B.
a reference to a structure
C.
a copy of a structure
D.
nothing
Answer: _________
Question 504:
The cout << sales[0] + sales[1]
statement will ______
A.
display 22000
B.
display 10000 + 12000
C.
display sales[0] + sales[1]
D.
result in an error
Answer: _________
Question 505:
Which of the following statements opens a file named temp.dat for output?
A.
outFile.open("temp .dat")
B.
fileOut.output("temp .dat")
C.
openFile.out("temp .dat")
D.
fileOpen.out("temp .dat")
Answer: _________
Question 506:
Which of the following will store the letter H in a Character variable named initial?
A.
initial = 'H'
B.
initial = 'H'
C.
initial = "H"
D.
initial = "H"
Answer: _________
Question 507:
The statement float values[]={3.14, -7.86, 36.96, 4.87}
A.
assigns 36.96 to values[2]
B.
assigns -7.86 to values[2]
C.
gives an error message
D.
assign 14 to values[2]
Answer: _________
Question 508:
You have declared an integer pointer called point You have also declared an integer called number. Which statement is the correct format?
A.
point = number
B.
point = *number
C.
point = &number
D.
point = +number
Answer: _________
Question 509:
A function that is prototyped as double calculate(int num)
may ______
A.
receive a double constant such as 3.9
B.
receive a double variable
C.
either (a) or (b)
D.
neither (a) nor (b)
Answer: _________
Question 510:
Which of the following will increase the value stored in the first element of the fee array by 2?
A.
amount[0] = amount[0] + 2
B.
amount, fee[0] = amount, fee [0] + 2
C.
feelnfo.amount[0] = feelnfo.amount[0] + 2
D.
fee[0].amount = fee[0].amount + 2
Answer: _________
Question 511:
Which of the following statements creates and initializes a pointer named salesPtr?
A.
salesPtr = NULL
B.
*salesPtr = ""
C.
float &salesPtr = NULL
D.
float *salesPtr = ""
Answer: _________
Question 512:
With communicational cohesion
A.
a tasks and the data are related
B.
the tasks are related
the data are not
C.
the data are related
the tasks are not
D.
the tasks and the data are unrelated
Answer: _________
Question 513:
To use the this pointer with a member function, you _____
A.
declare this as static
B.
declare this as global
C.
define this as equal to the address of the appropriate object
D.
do nothing
it is automatically supplied for you
Answer: _________
Question 514:
A function that is prototype as int calculate(int num)
may
A.
receive an integer variable named num from the main() program
B.
receive any integer variable from the main() program
C.
either (a) or (b)
D.
neither (a) nor (b)
Answer: _________
Question 515:
Assume that a program includes the short *agePtr = NULL
statement. The name of the pointer is _____
A.
*agePtr
B.
age*Ptr
C.
agePtr
D.
NULL
Answer: _________
Question 516:
Which of the following creates a String named constant called partNo, whose value is AB45?
A.
const char[4] partNo = "AB45"
B.
const char[5] partNo = 'AB45'
C.
const char[5] partNo = "AB45"
D.
const char partNo[5] = "AB45"
Answer: _________
Question 517:
The function whose prototype is void getData(Item &thing)
receives
A.
a pointer to a structure
B.
a reference to a structure
C.
a copy of a structure
D.
nothing
Answer: _________
Answer Key
1:
D
2:
A
3:
D
4:
B, H, L
5:
C
6:
B
7:
D
8:
D
9:
B
10:
B
11:
B
12:
A
13:
B
14:
D
15:
D
16:
A
17:
A
18:
A
19:
A
Solution: In the given expression, we have two conditions connected by the logical OR operator ( || ): - 4 > 6 : This condition is false because 4 is not greater than 6. - 10 < 2 * 6 : This condition is true because 10 is less than 12 (2 multiplied by 6). The logical OR operator ( || ) returns true if at least one of the conditions is true. In this case, the second condition is true, so the overall expression is true. So, the correct answer is Option A: True .
20:
B
21:
C
22:
C
23:
D
24:
D
25:
A
26:
B
27:
D
28:
A
29:
C
30:
C
31:
B
32:
B
33:
A
34:
B
35:
A
36:
A
37:
C
38:
A
39:
D
40:
B
41:
B
42:
A
Solution: The expression c = i++ is an example of the post-increment operator in C++. In the post-increment operation, the current value of i is assigned to c first. After this assignment, the value of i is incremented by 1 . Option A: the value of i assigned to c and then i incremented by 1 - This is correct because it accurately describes the post-increment behavior. Option B: i to be incremented by 1 and then the value of i assigned to c - This is incorrect because it describes the pre-increment operation, not post-increment. Option C: value of i assigned to c - This is incomplete because it doesn't mention the increment operation. Option D: i to be incremented by 1 - This is incorrect because it doesn't mention the assignment to c. Option E: None of the above - This is incorrect because Option A is correct. Therefore, the correct answer is Option A: the value of i assigned to c and then i incremented by 1 .
43:
D
44:
B
45:
A
46:
C
47:
B
48:
D
49:
F, K, P
50:
N/A
51:
N/A
52:
C
53:
B
54:
A
55:
B
56:
C
57:
C
58:
D
59:
A
60:
D
61:
C
62:
A
63:
D
64:
D
65:
A
66:
D
67:
A
68:
B
69:
A
70:
D
71:
B, F
72:
D
73:
D
74:
D
75:
B
76:
B
77:
A
78:
B
79:
N/A
80:
D
81:
C
82:
D
83:
A
84:
B
85:
A
86:
C
87:
C
88:
D
89:
D
90:
C
91:
A
92:
C
93:
D
94:
C
95:
A
96:
B
97:
A, E
98:
C
99:
D
100:
B
101:
C
102:
C
103:
C
104:
B
105:
A
106:
B
107:
D
108:
B
109:
B
110:
A, E
111:
C
112:
C
113:
B
114:
D
115:
A
116:
C
117:
C
118:
A
119:
A
120:
B, F
121:
C
122:
A, E
123:
D
124:
C
125:
C
126:
A
127:
C
128:
C
129:
D
130:
C
131:
D
132:
B
133:
A
134:
A
135:
A
136:
C
137:
C
138:
A
139:
B
140:
C
141:
C
142:
C
143:
A
144:
A
145:
A
146:
C, E
147:
B
148:
D
149:
B
150:
C
151:
D
152:
B
153:
C
154:
B
155:
N/A
156:
B
157:
D
158:
B
159:
N/A
160:
C
161:
C
162:
A
163:
B
164:
C
165:
B
166:
A
167:
C
168:
A
169:
B
170:
A
171:
B
172:
B
173:
B
174:
C
175:
A
176:
B
177:
D
178:
A
179:
C
180:
B
181:
B, E
182:
B
183:
B
184:
C
185:
D
186:
C
187:
C
188:
D
189:
D
190:
N/A
191:
A
192:
C
193:
B
194:
C
195:
C
196:
B
197:
D
198:
C
199:
C
200:
A
201:
C
202:
C
203:
C
204:
C
205:
B
206:
C
207:
C
208:
A
209:
A, E
210:
C
211:
B
212:
A
213:
A
214:
N/A
215:
D
216:
B
217:
A
218:
A
Solution: A. True. C++ is a multi-paradigm programming language, which means it supports multiple programming paradigms, including procedural and object-oriented programming. Procedural programming is a programming paradigm that emphasizes the use of procedures or functions to organize the program into small, reusable blocks of code. C++ supports procedural programming through the use of functions, structures, and arrays. Object-oriented programming, on the other hand, is a programming paradigm that emphasizes the use of objects, which are instances of classes, to organize the program. C++ supports object-oriented programming through the use of classes, inheritance, polymorphism, and other object-oriented concepts. Thus, C++ can be used as both a procedural and an object-oriented language, depending on the needs of the programmer and the requirements of the problem being solved.
219:
C
220:
B
221:
A
222:
C
223:
B
224:
N/A
225:
C
226:
B
227:
B
228:
D
229:
C
230:
A
231:
A
232:
C
233:
N/A
234:
B
235:
A
236:
B
237:
B
238:
C
239:
A
240:
B
241:
D
242:
A
243:
D
244:
A
245:
B
246:
D
247:
D
248:
N/A
249:
D
250:
B
251:
C
252:
B
253:
B
254:
B
255:
D
256:
C
257:
B
258:
B, F
259:
D
260:
C
261:
A
Solution: You define a structure type globally because you save many lines of code by not rewriting an identical structure definition in each function that uses it. Defining a structure globally ensures that all functions within the program can access and use the same structure definition without redundancy. This practice promotes code reusability and maintainability, as changes to the structure only need to be made in one place. Defining structures globally is not a requirement in C++, but it is a common practice to avoid repetitive code and potential inconsistencies.
262:
B
263:
C
264:
C
265:
C
266:
A
267:
C
268:
C
269:
A
270:
B
271:
A
272:
B, F
273:
A
274:
A
275:
A
276:
B
277:
C
278:
A, E
279:
C
280:
C
281:
A
282:
C
283:
D
284:
A
285:
D
286:
C
287:
C
288:
A
289:
D
290:
C
291:
C
292:
D
293:
B
294:
A
295:
B
296:
A
297:
A
298:
A
299:
D
300:
A
301:
A
302:
A
303:
A
304:
N/A
305:
C
306:
C
307:
A
308:
C
309:
B
310:
D
311:
D
312:
C
313:
B
314:
D
315:
N/A
316:
C
317:
D
318:
B
319:
A
320:
A
321:
D
322:
A
323:
C
324:
C
325:
B
326:
A
327:
A
328:
C
329:
A
330:
D
331:
A
332:
C
333:
B
Solution: The insertion operator in C++ is used to insert data into an output stream, such as cout . Option A: >> - This is the extraction operator, used to extract data from an input stream, such as cin . Option B: << - This is the insertion operator, used to insert data into an output stream, such as cout . Option C: // - This denotes a single-line comment in C++. Option D: / - This denotes the beginning of a multi-line comment in C++, which ends with / . Option E: both (a) and (b) - This is incorrect because only Option B: << is the insertion operator. Therefore, the correct answer is Option B: << .
334:
A
335:
B
336:
C
337:
B
338:
D
339:
B
340:
D
341:
B
342:
A
343:
C
344:
B
345:
A
346:
B
347:
C
348:
A
349:
B
350:
B
351:
B
352:
C
353:
C
354:
A
355:
A
356:
C
357:
D
358:
A
359:
C
360:
C
361:
A
362:
A
363:
B
364:
A
365:
A
366:
C
367:
C
368:
N/A
369:
B
370:
D
371:
C
372:
C
373:
A
374:
D
375:
A
376:
A
377:
D
378:
A
379:
B
380:
D
381:
C
382:
A
383:
C
384:
C
385:
B
386:
B
387:
A
388:
B
389:
A
390:
A
391:
A
392:
B
393:
B
394:
D
395:
B
396:
D
397:
D
398:
A
399:
D
400:
B
401:
A
402:
C
403:
C
404:
C
405:
C
406:
A
407:
C
408:
D
409:
A
410:
B
411:
D
412:
A
413:
D
414:
A
415:
C
416:
D
417:
C
418:
A
419:
C
420:
C
421:
B
422:
C
423:
C
424:
C
425:
A
426:
C
427:
N/A
428:
B
429:
C
430:
B
431:
A
432:
C
433:
B
434:
A
435:
C
436:
C
437:
C
438:
C
439:
D
440:
C
441:
N/A
442:
A
443:
A
444:
D
445:
A
446:
C
447:
C
448:
B
449:
C
450:
C
451:
C
452:
A
453:
D
454:
C
455:
C
456:
C
457:
B
458:
B
459:
C
460:
A, E
461:
B
462:
A
463:
A
464:
A
465:
D
466:
C
467:
C
468:
C
469:
D
470:
C, G
471:
C
472:
A
473:
A
474:
D
475:
B
476:
A
477:
B
478:
D
Solution: sqrt is a function from the C++ standard library that calculates the square root of a given number. In this case, the expression sqrt(16) calculates the square root of 16. The function pow from the C++ standard library calculates the power of a number, i.e., it raises a number to a specified power. The expression pow(16, 2) calculates 16 raised to the power of 2, which is 256, and is not the square root of 16. sqroot is not a standard C++ function and will result in a compile-time error. sqrt (16, 2) is not a correct syntax for the sqrt function in C++, which takes only one argument, the number for which the square root is to be calculated. So, the correct expression to find the square root of 16 in C++ is sqrt(16) . C++ program to find out square root of 16 #include <iostream>
#include <cmath>
using namespace std
int main() {
cout << "Square root of 16 = "
// print the square root of 16
cout << sqrt(16)
return 0
} Here is an explanation of the code: 1. #include <iostream> - This line includes the input/output stream library, which provides the cout function that is used later in the code to print the output. 2. #include <cmath> - This line includes the C++ mathematics library, which provides mathematical functions such as sqrt() that is used later in the code to calculate the square root. 3. using namespace std
- This line is used to make all the elements of the standard C++ library available to the program. 4. int main() - This is the main function of the program. All C++ programs must have a main function, which is where the program starts executing. 4. cout << "Square root of 16 = "
- This line outputs the string "Square root of 16 =" to the console. 6. cout << sqrt(16)
- This line calculates the square root of 16 using the sqrt() function from the C++ mathematics library and outputs the result to the console. 7. return 0
- This line is the return statement of the main function. It returns 0, indicating that the program has executed successfully. In summary, this program calculates the square root of 16 and outputs the result to the console.
479:
D
480:
C
481:
D
482:
B
483:
N/A
484:
B
485:
B
486:
B
487:
C
488:
C
489:
D
490:
B
491:
N/A
492:
D
493:
D
494:
A
495:
N/A
496:
D
497:
A
Solution: Correct Answer: A: optional Here's why: In a `switch` statement, the `break` statement is optional . How a `switch` works (Simplified): A `switch` statement checks a variable against different `case` values. If a `case` matches, the code under that `case` starts executing. `break`'s role: The `break` statement tells the program to immediately exit the `switch` statement . What happens without `break`? If you *don't* include a `break` after a `case`, the program will "fall through" to the next `case` and continue executing code there, even if that next `case` doesn't match the original variable's value. This "fall-through" behavior can be useful in some situations, but often you want to execute only the code associated with a single `case`. Example: Imagine a traffic light. `switch (trafficLightColor)` { `case "red":` `Stop()
` `break
` // Without this, it might also execute the "yellow" code! `case "yellow":` `SlowDown()
` `break
` `case "green":` `Go()
` `break
` `}` So, while `break` is very common and important for controlling the flow of execution in a `switch`, it's not required by the C++ language . The program will still compile and run (though perhaps not as intended) without it.
498:
B
499:
B
500:
B
501:
D
502:
D
503:
A
504:
A
505:
A
506:
B
507:
A
508:
C
509:
D
510:
D
511:
N/A
512:
C
513:
D
514:
C
515:
C
516:
D
517:
B