Final Exam - csis2610

glintplainvilleSoftware and s/w Development

Nov 18, 2013 (3 years and 10 months ago)

1,304 views

Final Exam


True/False

Indicate whether the statement is true or false.


____

1.

One
-
dimensional arrays are sometimes referred to as vectors.


____

2.

Each item in an array is called an element or component of the array.


____

3.

grade[5]

refers to the fifth grade stored in the grade array.


____

4.

Subscripted variables can be used anywhere that scalar variables are valid.


____

5.

A structured data type is any type with values that can be separated into simpler data types related by some

defined structure.


____

6.

Array elements can be initialized within their declaration statements in the same manner as scalar variables,
except that the initializing elements must be included in braces.


____

7.

Forgetting to declare an array is a common

programming error.


____

10.

*numAddr

means the variable whose address is stored in
numAddr
.


____

11.

Offsets may be included in expressions using pointers.


____

12.

An array name is a pointer constant, and the address stored in the pointer can be
changed by an assignment
statement.


____

13.

Expressions that take the address of an array name are invalid because the pointer created by the compiler is
internal to the computer, not stored in memory as are pointer variables.


____

14.

The
new

and
delet
e

operators provide a mechanism for enlarging and shrinking arrays.


____

15.

The expression
total = total + *nPt++

is a standard accumulating expression.


____

16.

A “pure” object
-
oriented language must always use classes.


____

17.

An object’s behavior d
efines how the object appears at the moment.


____

18.

Although an initial capital letter is not required, it is conventionally used to designate a class.


____

19.

The class declaration and implementation section of a C++ class definition declares the cla
ss and creates
variables of the class.


____

20.

Default values cannot be used in a constructor function.


____

21.

The values contained in an object’s data members have no bearing on the object’s state.



____

23.

An operator function’s name is always of
the form
operator<symbol>
, where
<symbol>

is one of the
operators available for class use.


____

24.

A C++ operator that is unary cannot be changed to a binary operator, and a binary operator cannot be changed
to a unary operator.


____

25.

An operator
symbol can be used to produce any operation, whether or not the operation is consistent with the
symbol’s accepted use.


____

26.

Neither the precedence nor the associativity of C++’s operators can be modified.


____

27.

Although assignment looks similar t
o initialization, they’re entirely different operations.


____

28.

In making the determination to overload a binary operator as either a friend or a member operator function,
the following convention can be applied: member functions are more appropriate fo
r binary functions that
modify neither of their operands, such as
==

+, and
-
, whereas friend functions are more appropriate for
binary functions, such as =, +=, and
-
= that are used to modify one of their operands.


____

29.

When an object is passed to a
method, the method receives a copy of it.


____

30.

Converting from a class data type to a class data type is done in the same manner as a conversion from a class
to a built
-
in data type

by using a conversion operator function.


____

31.

Converting between

classes clearly implies having two classes: One is always defined first, and one is defined
second.


____

32.

The ability to create new classes from existing classes does not necessarily promote code reuse.


____

33.

Polymorphism and inheritance are unrel
ated concepts.


____

34.

Polymorphism permits the same method name to invoke one operation in objects of a parent class and a
different operation in objects of a derived class.


____

35.

Encapsulation is not provided by C++’s class capability.


____

36.

A
derived class has a declaration but no implementation.


____

37.

To retain restricted access across derived classes, C++ provides a third access specification

protected.


____

38.

A derived class defines the type of inheritance it is willing to take on, su
bject to the base class’s access
restrictions.


____

39.

Base and derived classes share a common set of data member types.


____

40.

In the absence of an explicit derived class constructor, the compiler automatically calls the default base class
constructo
r first, before the derived class constructor is called.


____

41.

After a function is declared as virtual, it remains virtual for the next derived class, with or without a virtual
declaration in the derived class.


____

42.

After a function has been decla
red as virtual, the return type and parameter list of all subsequent derived class
override versions
must
change.


____

43.

As each object is defined in a program, the compiler designates enough storage for it.


____

44.

After an existing object’s address
is overwritten with a new object’s address, there’s no way for the system to
reclaim the memory.


____

45.

The statement
getline(cin, message, ‘
\
n’);

can be used in place of the statement
getline(cin, message);


____

46.

The statements:

cout >> "
\
n"

and

cout >> '
\
n'

both produce a new line on the screen.


____

47.

string s1 = 'a';

is an invalid initialization.


____

48.

The Enter key is not a legitimate character input.


____

49.

Uppercase characters are mathematically greater than lowercase characters.


____

50.

The central element in user
-
input validation is checking each entered character to verify that it qualifies as a
legitimate character for the expected data type.


Multiple Choice

Identify the choice that best completes the statement or answers the

question.


____

1.

A one
-
dimensional array is a list of related values with the same ____ that is stored using a single group
name.

a.

size

c.

value

b.

data type

d.

offset



____

2.

The statements
const int NUMELS = 4;

and
char code[NUMELS];

create an array with storage
reserved for ____.

a.

one byte

c.

four characters

b.

four bytes

d.

four words



____

3.

If an array is declared with the statements
const int AA = 3;

and
double arrayA[AA];

the index
of the last element in the array is ____.

a.

0

c.

2

b.

1

d.

3



____

4.

Referencing the first element of an array with an index of zero increases the ____ of the computer when it
accesses array elements.

a.

accuracy

c.

security

b.

logic

d.

speed



____

5.

Any expression that evaluates to a(n)

____ may be used as a subscript.

a.

integer

c.

scalar

b.

constant

d.

offset



____

6.

The structure often used to sequence through an array is the ____.

a.

do loop

c.

for loop

b.

do while loop

d.

linked list



____

7.

The statement
cin >> grade[4] >>
prices[6];

causes ____ values to be read and stored.

a.

2

c.

6

b.

4

d.

10



____

8.

Using ____ helps to eliminate the problem of using out of bounds indices.

a.

subroutines

c.

symbolic constants

b.

functions

d.

interactive input



____

9.

One
-
dimensional arrays are examples of a(n) ____ type.

a.

composed

c.

structured

b.

primitive

d.

atomic



____

10.

Consider the declarations
const int ARRAYSIZE = 7;

and
double length[ARRAYSIZE] =
{7.8, 6.4, 4.9, 11.2};
.
How many elements will be
initialized to zero?

a.

none

c.

two

b.

one

d.

three



____

11.

A C
-
string is terminated with ____.

a.

the newline character

c.

a square bracket

b.

the null character

d.

a semicolon



____

12.

When passing an array to a called function, the function
receives ____ array.

a.

a copy of the

c.

the first element of the

b.

selected elements of the

d.

access to the actual



____

13.

If a two
-
dimensional array is initialized within a declaration statement, the ____ can be omitted.

a.

outer braces

c.

commas

b.

inner braces

d.

array elements



____

14.

The initialization of a two
-
dimensional array is done in ____ order.

a.

page

c.

row

b.

column

d.

data element



____

15.

If a nested loop is used to process a two
-
dimensional array, the inner loop
corresponds to ____ elements.

a.

row

c.

data

b.

page

d.

column



____

16.

Assuming four bytes for an
int
, and a column size of 4, if
val

is an
int

array, the array element
val[1][3]

is located at an offset of ____ bytes from the start of the array.

a.

4

c.

16

b.

12

d.

28



____

17.

A six
-
dimensional array can be viewed as a mathematical
n
-
tuple of order ____.

a.

five

c.

seven

b.

six

d.

ten



____

18.

Many compilers automatically set all elements of integer
-
valued and real
-
valued arrays to ____.

a.

blanks

c.

null

b.

zeros

d.

ones



____

19.

A linear search is also known as a(n) ____ search.

a.

ordered

c.

selection

b.

binary

d.

sequential



____

20.

USing

a linear search, the average number of comparisons needed to find an element in an alphabetized list of
length
n

is ____.

a.

n
/2

c.

n
2

b.

n

d.

n
!



____

21.

The value of using a binary search algorithm is that the number of elements that must be
searched is ____ for
each pass through the data.

a.

reduced by one

c.

cut in half

b.

reduced by ten

d.

reduced by 90%



____

22.

The big O of a search algorithm refers to the ____ of comparisons required to locate a desired item.

a.

number

c.

average
number

b.

order of magnitude of the number

d.

maximum number



____

23.

In a bubble sort, on each pass through the list, the largest element ____.

a.

is eliminated

c.

rises to the top of the list

b.

sinks to the bottom of the list

d.

is combined with
the next largest



____

24.

The order of bubble sort is ____.

a.

O(
n
)

c.

O(
n
2
)

b.

O(2
n
)

d.

O(
n
!)



____

25.

For ____ data, the selection sort generally performs as well as or better than the bubble sort.

a.

ordered

c.

random

b.

binary

d.

integer



____

26.

Every variable has three major items associated with it: the value stored in the variable, the number of bytes
reserved for the variable, and the bytes’ ____.

a.

precision

c.

accuracy

b.

size

d.

address



____

27.

The address of a variable is
the memory location of the ____ byte reserved for the variable.

a.

first

c.

middle

b.

last

d.

largest



____

28.

The number of bytes required for an integer pointer is ____.

a.

one

c.

eight

b.

four

d.

compiler
-
dependent



____

29.

Pointers are simply
____ that are used to store the addresses of other variables.

a.

prototypes

c.

variables

b.

data types

d.

addresses



____

30.

Using a pointer to find the value of a variable is called ____.

a.

pointer arithmetic

c.

indirect addressing

b.

tracing a
pointer

d.

tracing a value



____

31.

C++ requires that when we declare a pointer variable, we also specify the ____ of the variable that is pointed
to.

a.

value

c.

size

b.

address

d.

data type



____

32.

For dynamic allocation of memory to create new
variables as a program is running, pointers are ____.

a.

required

c.

not allowed

b.

helpful

d.

allowed



____

33.

A reference is a pointer with ____ capabilities.

a.

expanded

c.

unlimited

b.

restricted

d.

computational



____

34.

Using a reference to access the value of a variable without the need for explicitly using the indirection
operator symbol(*) is referred to as a(n) ____.

a.

automatic access

c.

variable access

b.

quick lookup

d.

automatic dereference



____

35.

If
grade

is a single
-
dimension array containing five integers, and there are four bytes per integer,
&grade[3]

is computed as ____.

a.

&grade[3] + 4

c.

&grade[0] + 4

b.

&grade[0]*4

d.

&grade[0] + (3 * 4)



____

36.

The
1

in the expression
*(gPtr + 1)

is a(n)
____.

a.

word

c.

offset

b.

byte

d.

scale



____

37.

Any subscript used by a programmer is automatically converted to a(n) ____ by the compiler.

a.

integer

c.

offset

b.

expression

d.

equivalent pointer expression



____

38.

A pointer constant is ____ a
pointer variable created by a programmer.

a.

equivalent to

c.

very similar to

b.

identical to

d.

completely different from



____

39.

When an offset is added to a pointer, the address in the pointer is ____.

a.

not changed

c.

eliminated

b.

temporarily
changed

d.

overwritten



____

40.

For each array created, the name of the array becomes the name of the pointer constant created by the
compiler for the array, and the ____ of the first location reserved for the array is stored in this pointer.

a.

offset

c.

starting address

b.

byte count

d.

offset address



____

41.

The purpose of an array name is to ____ the beginning of the array correctly.

a.

assign

c.

offset

b.

declare

d.

locate



____

42.

If
grade

is an array, trying to store its address using the expression
&grade

results in a ____.

a.

program crash

c.

compiler error

b.

normal execution

d.

scaling error



____

43.

Under a dynamic allocation scheme, the amount of storage to be allocated is
determined and adjusted ____.

a.

at compile time

c.

when a program error occurs

b.

at runtime

d.

interactively by the user



____

44.

Dynamic storage requests for scalar variables or arrays are made ____.

a.

automatically by the compiler

b.

interactively by the user

c.

as part of a declaration or assignment statement

d.

in special functions



____

45.

The only address required by the
delete

operator is the ____ address of the block of storage that was
dynamically allocated.

a.

pointer

c.

starting

b.

offset

d.

ending



____

46.

The manipulation of addresses using pointers ____ knowledge of the actual addresses.

a.

requires

c.

often requires

b.

generally does not require

d.

never requires



____

47.

Adding 1 to a pointer causes the
pointer to point to the ____.

a.

next element of the type pointed to

c.

next byte

b.

first element of the type pointed to

d.

next block



____

48.

Explicitly passing addresses to a function using the address operator effectively is a(n) ____.

a.

pass by
value

c.

pointer initialization

b.

pass by reference

d.

automatic dereference



____

49.

When an array is passed to a function, its ____ is the only item actually passed.

a.

value

c.

address

b.

data type

d.

offset



____

50.

A pointer ____ included as
a parameter in a function header.

a.

can not be

c.

should not be

b.

can be

d.

is rarely



____

51.

Languages that use classes but do not provide inheritance and polymorphic features are referred to as ____
languages.

a.

object
-
oriented

c.

procedural

b.

object
-
based

d.

hybrid



____

52.

In a pure object
-
oriented language, it is ____ not to use object
-
oriented features throughout a program.

a.

easy

c.

impossible

b.

difficult

d.

possible



____

53.

In a hybrid language, such as C++, it is ____ not to use

elements of a procedural program.

a.

easy

c.

impossible

b.

difficult

d.

possible



____

54.

Data members of a
class

are also known as ____.

a.

instance variables

c.

manipulators

b.

data elements

d.

initializers



____

55.

The private access
designation used in C++ classes restricts a user from seeing how the data is actually stored
and is referred to as data ____.

a.

security

c.

enforcement

b.

protection

d.

hiding



____

56.

The class ____ section is where the member methods declared in the

declaration section are written to permit
the initialization, assignment, and display capabilities implied by their names.

a.

constructor

c.

initialization

b.

assignment

d.

implementation



____

57.

The ____ operator is used to show a function’s
membership in a class.

a.

insertion

c.

scope resolution

b.

assignment

d.

inclusion



____

58.

Class functions declared as
public

____ be called by any objects and functions not in the class.

a.

can

c.

must only

b.

cannot

d.

should rarely



____

59.

When a new object is defined, memory is allocated for the object, and its data members are initialized
automatically by a call to the class ____ method.

a.

implementation

c.

constructor

b.

declaration

d.

extension



____

60.

If a class designates all of
its data members as private and all of its member functions as public, we must rely
on ____ to access data members.

a.

scope resolution operators

c.

assignment statements

b.

member functions

d.

equivalence statements



____

61.

A(n) ____ consists of a
class’s public member method declarations and any supporting comments.

a.

interface

c.

environment

b.

specification

d.

component



____

62.

Objects have the same relationship to classes as ____ do to C++ built
-
in data types.

a.

constants

c.

instances

b.

variables

d.

cases



____

63.

A class ____ consists of the operations permitted to be performed on an object’s data members.

a.

instantiation

c.

behavior

b.

environment

d.

state



____

64.

If no constructor is provided in a class definition, the
compiler will ____.

a.

supply a stub

c.

issue an error message

b.

do nothing

d.

supply a do
-
nothing default constructor



____

65.

When a constructor function is used in a declaration, parentheses should ____ be included for a zero
parameter constructor.

a.

always

c.

usually

b.

never

d.

rarely



____

66.

Date c = Date(4,1,2009)

is a valid ____ language declaration for an object of a class named
Date
.

a.

C++

c.

assembler

b.

C

d.

machine



____

67.

C++ constructors may be ____.

a.

overloaded

c.

aliased

b.

classes

d.

interfaces



____

68.

Constructors may have which of the following attributes?

a.

default arguments

c.

inline

b.

overloading

d.

All of the above



____

69.

There can be ____ destructor function(s) per class.

a.

one

c.

three

b.

two

d.

any

number of



____

70.

A mutator method ____ an object’s data values.

a.

instantiates

c.

destroys

b.

defines

d.

changes



____

71.

Functions that change an object’s data values are commonly referred to as ____.

a.

accessor functions

c.

mutator functions

b.

destructive functions

d.

non
-
member functions



____

72.

The term information hiding refers to the ____ and hiding of all implementation details.

a.

encryption

c.

encapsulation

b.

translation

d.

destruction



____

73.

From a coding standpoint, the
friends list is simply a series of method prototype declarations preceded with
the keyword ____ and included in the class declaration section.

a.

static

c.

external

b.

friend

d.

global



____

74.

Regarding an object, ____ define the properties of
interest.

a.

attributes

c.

methods

b.

behaviors

d.

members



____

75.

A(n) ____ diagram identifies the required object and lists its relevant attributes and behaviors.

a.

class

c.

software design

b.

object description

d.

UML



____

76.

The ____
operator can be redefined for class use.

a.

+

c.

::

b.

.

d.

?:



____

77.

Operations on class objects that use C++’s built
-
in operator symbols are referred to as ____ functions.

a.

symbol

c.

class

b.

friend

d.

operator



____

78.

In defining a member
function, passing a reference is preferable to passing an object, because it reduces the
function call’s ____.

a.

overhead

c.

error rate

b.

execution time

d.

compile time



____

79.

If
a

and
b

are objects of type
Date
, the expression
if (a == b)

____.

a.

in invalid

c.

causes a compile error

b.

is valid

d.

causes a run time error



____

80.

Assuming
a

and
b

are objects with an overloaded
==

operator, rather than using the expression
a
==

b

we
could have used the call ____.

a.

a.operator
==

(b)

c.

operator = a.b

b.

a = b.operator

d.

b.operator = a



____

81.

A suitable name for an operator function that adds two quantities would be ____.

a.

addition

c.

+operator

b.

++

d.

operator+



____

82.

Operators ____ be redefined for C++’s built
-
in types.

a.

can

c.

usually can

b.

cannot

d.

usually cannot



____

83.

The ____ operator is the one operator that works with all classes without requiring an operator function.

a.

copy

c.

cast

b.

assignment

d.

conversion



____

84.

An operator to be defined for
class use must either be a member of a class or be defined to ____.

a.

be a friend function

b.

be a virtual function

c.

take at least one class member as an operand

d.

take no operands



____

85.

The compiler’s default ____ constructor performs similarly to the default assignment operator by doing a
memberwise assignment between objects.

a.

initialization

c.

copy

b.

cast

d.

conversion



____

86.

Copy constructors, like all operator functions, are

declared in the class ____ section.

a.

initialization

c.

implementation

b.

definition

d.

declaration



____

87.

A true initialization has no reliance on assignment and is possible in C++ by using a(n) ____ initialization list.

a.

class

c.

static

b.

operator

d.

base/member



____

88.

If a class member function unary operator is rewritten as a friend function it will have ____ argument(s).

a.

one implicit and one explicit

c.

one explicit

b.

two explicit

d.

one implicit



____

89.

Note that each set
of data members has its own starting address in memory, which corresponds to the address
of the object’s ____.

a.

name

c.

implementation section

b.

declaration section

d.

first data member



____

90.

When a method is called, the calling object’s address
is passed to it and stored in the method’s ____ pointer.

a.

this

c.

class

b.

starting

d.

code



____

91.

The general expression
(*pointer).member

can always be replaced with the notation ____.

a.

*(pointer.member)

c.

pointer
-
>member

b.

*(pointer
-
>
member)

d.

member
-
>pointer



____

92.

Conversion from a user
-
defined data type to a built
-
in data type is accomplished using a(n) ____.

a.

member conversion operator function

c.

type conversion constructor

b.

conversion operator function

d.

implicit
conversion



____

93.

A built
-
in to built
-
in conversion is handled by C++’s implicit conversion rules or its explicit ____ operator.

a.

cast

c.

symbol

b.

class

d.

conversion



____

94.

A conversion from a built
-
in data type to a class is made by using
____.

a.

operator functions

c.

class operators

b.

conversion methods

d.

constructor methods



____

95.

A(n) ____ constructor is any constructor whose first argument is
not
a member of its class and whose
remaining arguments, if any, have default values.

a.

operator

c.

type conversion

b.

friend

d.

cast



____

96.

Converting from a class data type to a class data type is done by using a(n) ____.

a.

class constructor

c.

type conversion constructor

b.

conversion operator function

d.

type conversion friend
function



____

97.

In programming terms, an object’s attributes are described by ____.

a.

its behavior

c.

its state

b.

constants

d.

data



____

98.

____ means concentrating on what an object is and does before making any decisions about how to
implement the object.

a.

Abstraction

c.

Information hiding

b.

Encapsulation

d.

Interface



____

99.

____ generally means separating the implementation details of the abstract attributes and behavior and hiding
them from the object’s outside users.

a.

Information hiding

c.

Encapsulation

b.

Abstraction

d.

Modeling



____

100.

An advantage of the ____ object approach is that it encourages extending existing code without needing to
completely rewrite it.

a.

past
-
present

c.

dynamic

b.

inside
-
outside

d.

open



____

101.

Constructing one class from another is accomplished by using a capability called ____.

a.

inheritance

c.

code reuse

b.

polymorphism

d.

object
-
oriented programming



____

102.

A base class is a ____.

a.

derived class

c.

parent class

b.

child class

d.

subclass



____

103.

A derived class is a completely new class that incorporates ____ of the data and member functions of its base
class.

a.

some

c.

all

b.

most

d.

none



____

104.

A derived class ____ add its own new data and function
members to those of its parent class.

a.

cannot

c.

can and usually does

b.

can

d.

can but usually does not



____

105.

In multiple inheritance, a derived type has ____ or more base types.

a.

one

c.

three

b.

two

d.

four



____

106.

In order for a
programming language to be classified as an object oriented
-
language, it must provide the
features of classes, inheritance, and ____.

a.

dynamic memory allocation

c.

implicit conversions

b.

static memory allocation

d.

polymorphism



____

107.

Giving private access to a class’s data members ____ access by any derived class data members.

a.

precludes

c.

sometimes allows

b.

allows

d.

encourages



____

108.

____ access

behaves the same as private access, in that it permits access only to member or friend functions,
but it allows any derived class to inherit this restriction.

a.

Private

c.

Public

b.

Protected

d.

Package



____

109.

The class
-
access specifier

is listed ____ of its declaration section.

a.

after the colon at the start

c.

after the colon at the end

b.

before the colon at the start

d.

before the colon at the end



____

110.

If the base class member has a protected access and the derived class access specifier is
public
, the derived
class member is ____ to its class.

a.

private

c.

public

b.

blocked

d.

protected



____

111.

If the base class has a public access and the derived class access specifier is public, the derived class member
is ____.

a.

public

c.

blocked

b.

private

d.

protected



____

112.

Overriding a base member function by using an overloaded derived member fun
ction is an example of ____.

a.

polymorphism

c.

inheritance

b.

encapsulation

d.

information hiding



____

113.

In static binding, the determination of which function is called is made ____.

a.

at run time

c.

by the user

b.

in the program code

d.

at
compile time



____

114.

Dynamic binding is achieved in C++ with ____ functions.

a.

protected

c.

virtual

b.

friend

d.

overloaded



____

115.

A virtual function

specification tells the compiler to create a pointer to a function but not to fill in the
value of
the pointer until ____.

a.

the user responds to a prompt

c.

the function is actually called

b.

runtime

d.

compile time



____

116.

Creating a virtual function is easy

simply place

the keyword ____ before the function’s return type in the
class declaration section.

a.

virtual

c.

static

b.

friend

d.

protected



____

117.

With ____ allocation, the amount of storage to be allocated is assigned, as requested, at runtime instead of
being fixed at compile time.

a.

static

c.

fixed

b.

dynamic

d.

compiler



____

118.

For object
-
oriented programs, ____ allocation allows creating and destroying new objects as required.

a.

fixed

c.

static

b.

compiler

d.

dynamic



____

119.

After an
object has been dynamically created, it can be accessed only by using the address the ____ operator
returns.

a.

new

c.

delete

b.

this

d.

get



____

120.

It is a good practice to restore allocated storage back to the heap by using ____ when the memory is
no longer
needed.

a.

cleanup

c.

delete

b.

new

d.

restore



____

121.

Pointer related problems associated with a class default assignment operator also exist with the ____.

a.

assignment operator

c.

default copy constructor

b.

copy constructor

d.

default

constructor



____

122.

A good way to avoid pointer related problems associated with class default assignment operators is to ____.

a.

avoid the use of assignment

c.

explicitly write an assignment operator

b.

avoid the use of pointers

d.

avoid the use
of classes



____

123.

A common programming error is attempting to use memberwise assignment between objects that contain
____.

a.

char data

c.

too many objects

b.

errors

d.

pointer members



____

124.

Formally, the process of designing an application
is referred to as ____ modeling.

a.

class

c.

object

b.

system

d.

program



____

125.

____ diagrams are used to describe classes and their relationships.

a.

Class

c.

Program

b.

Object

d.

Model



____

126.

The ____ class provides a set of methods that
include easy insertion and removal of characters from a string.

a.

char

c.

exception

b.

ISO

d.

string



____

127.

The ____ character in a string is referred to as both the character’s index value and its offset value.

a.

first

c.

middle

b.

last

d.

largest



____

128.

string objectName = value

is an example of a(n) ____.

a.

assignment statement

c.

declaration statement

b.

constructor method

d.

implementation statement



____

129.

Pressing the Enter key at the terminal generates a newline character,

\
n’
, which is interpreted by
getline()

as ____.

a.

the end of data input

c.

the end
-
of
-
line entry

b.

the end of a block of data

d.

a keyboard error



____

130.

If the optional third argument is omitted when
getline()

is called, the default terminating character is
____.

a.

not defined

c.

the newline (

\
n’
)⁣ 慲慣t敲



t桥hrig桴⁢r慣攠e
}
)

d.

the extraction (
>>
) operator



____

131.

On almost all computer
systems, newly entered data is stored in a temporary holding area called a ____.

a.

register

c.

buffer

b.

cell

d.

memory location



____

132.

If the specified index is non
-
existent, the
at()

method ____.

a.

returns a negative value

c.

returns a positive
value

b.

throws an exception

d.

aborts the program



____

133.

The most commonly used string class method is ____.

a.

length()

c.

at()

b.

size()

d.

compare()



____

134.

The value returned by the method call
“Hello World!”.length()

is ____.

a.

10

c.

14

b.

12

d.

21



____

135.

Each character in a string is stored in ____ using either the ASCII or Unicode code.

a.

binary

c.

octal

b.

hexadecimal

d.

decimal



____

136.

____ return a nonzero integer when the character meets the desired condition,

and a zero when the condition
is not met.

a.

Character I/O methods

c.

String class processing methods

b.

istype()

functions

d.

Exception handlers



____

137.

All input and output is done on a ____ basis.

a.

bit
-
by
-
bit

c.

word
-
by
-
word

b.

byte
-
by
-
byte

d.

character
-
by
-
character



____

138.

All of C++’s higher
-
level I/O methods and streams are based on ____ methods.

a.

other higher
-
level

c.

character manipulation

b.

lower
-
level character

d.

string manipulation



____

139.

The ____ function returns the
next character on the stream, but does not remove it from the stream’s buffer.

a.

peek()

c.

get()

b.

put()

d.

putback()



____

140.

The
putback()

function places a character back on the stream so that it will be the ____ character read.

a.

first

c.

next

b.

last

d.

next
-
to
-
last



____

141.

One way to prevent the Enter key from being accepted as a legitimate character when using the
get()

method is to follow the
cin.get()

input with a call to ____.

a.

cin.peek()

c.

cout.put()

b.

cin.putback()

d.

cin.ignore()



____

142.

Requiring a function to return a specific value to indicate a specific error condition is ____ used in C++.

a.

never

c.

frequently

b.

rarely

d.

always



____

143.

The process of generating and passing an exception at the point
the error was detected is referred to as ____.

a.

error handling

c.

exception handling

b.

throwing an exception

d.

catching an exception



____

144.

____ of the statements within a
try

block should be capable of throwing an exception.

a.

None

c.

More
than one

b.

At least one

d.

All



____

145.

A
try

block must be followed by one or more ____ blocks.

a.

error

c.

exception

b.

throw

d.

catch



____

146.

In exception handling, multiple
catch

blocks can be provided as long as each
catch

block catches ____.

a.

an error

c.

a unique exception

b.

a unique data type

d.

at least one exception



____

147.

The first step in the input data validation process for numerical data is to ensure that the data is ____.

a.

of the correct length

c.

contained within one file

b.

complete

d.

of the correct type



____

148.

The
atoi()

C
-
string conversion function converts ____.

a.

a string to a double precision number

c.

an integer to a string

b.

a string to an integer

d.

an integer to a double
precision number



____

149.

The first step in creating a library is to encapsulate all of the desired functions and classes into one or more
____ and then store the complete code in one or more files.

a.

blocks

c.

methods

b.

functions

d.

namespaces



____

150.

Once a namespace has been created and stored in a file, it can be included within another file by supplying
a(n) ____ informing the compiler where the desired namespace is to be found, and including a using directive
instructing the compiler as t
o which particular namespace in the file to use.

a.

prototype

c.

preprocessor directive

b.

data definition

d.

exception handler

Final Exam

Answer Section


TRUE/FALSE



1.

ANS:

T

PTS:

1

REF:

292



2.

ANS:

T

PTS:

1

REF:

293



3.

ANS:

F

PTS:

1

REF:

294



4.

ANS:

T

PTS:

1

REF:

295



5.

ANS:

T

PTS:

1

REF:

297



6.

ANS:

T

PTS:

1

REF:

303



7.

ANS:

T

PTS:

1

REF:

323



8.

ANS:

F

PTS:

1

REF:

332



9.

ANS:

F

PTS:

1

REF:

333



10.

ANS:

T

PTS:

1

REF:

345



11.

ANS:

T

PTS:

1

REF:

356



12.

ANS:

F

PTS:

1

REF:

360



13.

ANS:

T

PTS:

1

REF:

360



14.

ANS:

T

PTS:

1

REF:

360



15.

ANS:

T

PTS:

1

REF:

367



16.

ANS:

T

PTS:

1

REF:

435



17.

ANS:

F

PTS:

1

REF:

435



18.

ANS:

T

PTS:

1

REF:

442



19.

ANS:

F

PTS:

1

REF:

446



20.

ANS:

F

PTS:

1

REF:

447



21.

ANS:

F

PTS:

1

REF:

449



22.

ANS:

F

PTS:

1

REF:

460



23.

ANS:

T

PTS:

1

REF:

493



24.

ANS:

T

PTS:

1

REF:

498



25.

ANS:

T

PTS:

1

REF:

498



26.

ANS:

T

PTS:

1

REF:

499



27.

ANS:

T

PTS:

1

REF:

500



28.

ANS:

F

PTS:

1

REF:

505



29.

ANS:

T

PTS:

1

REF:

514



30.

AN
S:

T

PTS:

1

REF:

525



31.

ANS:

T

PTS:

1

REF:

525



32.

ANS:

F

PTS:

1

REF:

539



33.

ANS:

F

PTS:

1

REF:

540



34.

ANS:

T

PTS:

1

REF:

541



35.

ANS:

F

PTS:

1

REF:

541



36.

ANS:

F

PTS:

1

REF:

541



37.

ANS:

T

PTS:

1

REF:

542



38.

ANS:

T

PTS:

1

REF:

542



39.

ANS:

T

PTS:

1

REF:

546



40.

ANS:

T

PTS:

1

REF:

546



41.

ANS:

T

PTS:

1

REF:

551



42.

ANS:

F

PTS:

1

REF:

551



43.

ANS:

T

PTS:

1

REF:

552



44.

ANS:

T

PTS:

1

REF:

556



45.

ANS:

T

PTS:

1

REF:

610



46.

ANS:

T

PTS:

1

REF:

612



47.

ANS:

T

PTS:

1

REF:

612



48.

ANS:

F

PTS:

1

REF:

613



49.

ANS:

F

PTS:

1

REF:

615



50.

ANS:

T

PTS:

1

REF:

633


MULTIPLE CHOICE



1.

ANS:

B

PTS:

1

REF:

292



2.

ANS:

C

PTS:

1

REF:

293



3.

ANS:

C

PTS:

1

REF:

294



4.

ANS:

D

PTS:

1

REF:

294



5.

ANS:

A

PTS:

1

REF:

295



6.

ANS:

C

PTS:

1

REF:

296



7.

ANS:

A

PTS:

1

REF:

296



8.

ANS:

C

PTS:

1

REF:

297



9.

ANS:

C

PTS:

1

REF:

297



10.

ANS:

D

PTS:

1

REF:

303



11.

ANS:

B

PTS:

1

REF:

304



12.

ANS:

D

PTS:

1

REF:

307



13.

ANS:

B

PTS:

1

REF:

314



14.

ANS:

C

PTS:

1

REF:

314



15.

ANS:

D

PTS:

1

REF:

316



16.

ANS:

D

PTS:

1

REF:

319



17.

ANS:

B

PTS:

1

REF:

320



18.

ANS:

B

PTS:

1

REF:

323



19.

ANS:

D

PTS:

1

REF:

325



20.

ANS:

A

PTS:

1

REF:

327



21.

ANS:

C

PTS:

1

REF:

332



22.

ANS:

B

PTS:

1

REF:

332



23.

ANS:

B

PTS:

1

REF:

337



24.

ANS:

C

PTS:

1

REF:

339



25.

ANS:

C

PTS:

1

REF:

339



26.

ANS:

D

PTS:

1

REF:

341



27.

ANS:

A

PTS:

1

REF:

341
-
342



28.

ANS:

D

PTS:

1

REF:

342



29.

ANS:

C

PTS:

1

REF:

345



30.

ANS:

C

PTS:

1

REF:

345



31.

ANS:

D

PTS:

1

REF:

348



32.

ANS:

A

PTS:

1

REF:

348



33.

ANS:

B

PTS:

1

REF:

350



34.

ANS:

D

PTS:

1

REF:

350



35.

ANS:

D

PTS:

1

REF:

355



36.

ANS:

C

PTS:

1

REF:

356



37.

ANS:

D

PTS:

1

REF:

358



38.

ANS:

C

PTS:

1

REF:

358



39.

ANS:

A

PTS:

1

REF:

358



40.

ANS:

C

PTS:

1

REF:

358
-
359



41.

ANS:

D

PTS:

1

REF:

360



42.

ANS:

C

PTS:

1

REF:

360



43.

ANS:

B

PTS:

1

REF:

360



44.

ANS:

C

PTS:

1

REF:

361



45.

ANS:

C

PTS:

1

REF:

362



46.

ANS:

B

PTS:

1

REF:

365



47.

ANS:

A

PTS:

1

REF:

365



48.

ANS:

B

PTS:

1

REF:

370



49.

ANS:

C

PTS:

1

REF:

375



50.

ANS:

B

PTS:

1

REF:

376



51.

ANS:

B

PTS:

1

REF:

435



52.

ANS:

C

PTS:

1

REF:

435



53.

ANS:

C

PTS:

1

REF:

435



54.

ANS:

A

PTS:

1

REF:

440



55.

ANS:

D

PTS:

1

REF:

442



56.

ANS:

D

PTS:

1

REF:

443



57.

ANS:

C

PTS:

1

REF:

443



58.

ANS:

A

PTS:

1

REF:

443



59.

ANS:

C

PTS:

1

REF:

446



60.

ANS:

B

PTS:

1

REF:

447



61.

ANS:

A

PTS:

1

REF:

448



62.

ANS:

B

PTS:

1

REF:

448



63.

ANS:

C

PTS:

1

REF:

449



64.

ANS:

D

PTS:

1

REF:

452



65.

ANS:

B

PTS:

1

REF:

453



66.

ANS:

B

PTS:

1

REF:

455



67.

ANS:

A

PTS:

1

REF:

455



68.

ANS:

D

PTS:

1

REF:

455



69.

ANS:

A

PTS:

1

REF:

458



70.

ANS:

D

PTS:

1

REF:

460



71.

ANS:

C

PTS:

1

REF:

460



72.

ANS:

C

PTS:

1

REF:

471



73.

ANS:

B

PTS:

1

REF:

478



74.

ANS:

A

PTS:

1

REF:

485



75.

ANS:

B

PTS:

1

REF:

485



76.

ANS:

A

PTS:

1

REF:

492
-
493



77.

ANS:

D

PTS:

1

REF:

493



78.

ANS:

A

PTS:

1

REF:

493



79.

ANS:

B

PTS:

1

REF:

495



80.

ANS:

A

PTS:

1

REF:

495



81.

ANS:

D

PTS:

1

REF:

495



82.

ANS:

B

PTS:

1

REF:

499



83.

ANS:

B

PTS:

1

REF:

499



84.

ANS:

C

PTS:

1

REF:

499



85.

ANS:

C

PTS:

1

REF:

500



86.

ANS:

D

PTS:

1

REF:

501



87.

ANS:

D

PTS:

1

REF:

503



88.

ANS:

C

PTS:

1

REF:

504



89.

ANS:

D

PTS:

1

REF:

508



90.

ANS:

A

PTS:

1

REF:

509



91.

ANS:

C

PTS:

1

REF:

510



92.

ANS:

B

PTS:

1

REF:

520



93.

ANS:

A

PTS:

1

REF:

520



94.

ANS:

D

PTS:

1

REF:

520



95.

ANS:

C

PTS:

1

REF:

524



96.

ANS:

B

PTS:

1

REF:

525



97.

ANS:

D

PTS:

1

REF:

535



98.

ANS:

A

PTS:

1

REF:

537



99.

ANS:

C

PTS:

1

REF:

537



100.

ANS:

B

PTS:

1

REF:

537



101.

ANS:

A

PTS:

1

REF:

540



102.

ANS:

C

PTS:

1

REF:

540



103.

ANS:

C

PTS:

1

REF:

540



104.

ANS:

C

PTS:

1

REF:

540



105.

ANS:

B

PTS:

1

REF:

540



106.

ANS:

D

PTS:

1

REF:

541



107.

ANS:

A

PTS:

1

REF:

541



108.

ANS:

B

PTS:

1

REF:

542



109.

ANS:

A

PTS:

1

REF:

542



110.

ANS:

D

PTS:

1

REF:

542



111.

ANS:

A

PTS:

1

REF:

542



112.

ANS:

A

PTS:

1

REF:

547



113.

ANS:

D

PTS:

1

REF:

549



114.

ANS:

C

PTS:

1

REF:

549



115.

ANS:

C

PTS:

1

REF:

549



116.

ANS:

A

PTS:

1

REF:

549



117.

ANS:

B

PTS:

1

REF:

552



118.

ANS:

D

PTS:

1

REF:

552



119.

ANS:

A

PTS:

1

REF:

554



120.

ANS:

C

PTS:

1

REF:

556



121.

ANS:

C

PTS:

1

REF:

567



122.

ANS:

C

PTS:

1

REF:

567



123.

ANS:

D

PTS:

1

REF:

568



124.

ANS:

D

PTS:

1

REF:

569



125.

ANS:

A

PTS:

1

REF:

570



126.

ANS:

D

PTS:

1

REF:

605



127.

ANS:

A

PTS:

1

REF:

606



128.

ANS:

B

PTS:

1

REF:

607



129.

ANS:

C

PTS:

1

REF:

609



130.

ANS:

C

PTS:

1

REF:

610



131.

ANS:

C

PTS:

1

REF:

611



132.

ANS:

B

PTS:

1

REF:

613



133.

ANS:

A

PTS:

1

REF:

615



134.

ANS:

B

PTS:

1

REF:

615



135.

ANS:

A

PTS:

1

REF:

615



136.

ANS:

B

PTS:

1

REF:

623



137.

ANS:

D

PTS:

1

REF:

625



138.

ANS:

B

PTS:

1

REF:

627



139.

ANS:

A

PTS:

1

REF:

628



140.

ANS:

C

PTS:

1

REF:

629



141.

ANS:

D

PTS:

1

REF:

631



142.

ANS:

C

PTS:

1

REF:

634



143.

ANS:

B

PTS:

1

REF:

635



144.

ANS:

B

PTS:

1

REF:

636



145.

ANS:

D

PTS:

1

REF:

637



146.

ANS:

B

PTS:

1

REF:

637



147.

ANS:

D

PTS:

1

REF:

649



148.

ANS:

B

PTS:

1

REF:

650



149.

ANS:

D

PTS:

1

REF:

659



150.

ANS:

C

PTS:

1

REF:

661