final practice Flashcards

(28 cards)

1
Q

A C++ class is similar to one of these.
A) inline function
B) header file
C) library function
D) structure
E) None of these

A

Answer: D

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Class declarations are usually stored here.
A) on separate disk volumes
B) in their own header files
C) in .cpp files, along with function definitions
D) under pseudonyms
E) None of these

A

Answer: B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

When the body of a member function is defined inside a class declaration, it is said to be ________.
A) static
B) global
C) inline
D) conditional
E) None of these

A

Answer: C

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

When a constructor function accepts no arguments, or does not have to accept arguments because of
default arguments, it is called a(n) ________.
A) empty constructor
B) default constructor
C) stand-alone function
D) arbitrator function
E) None of these

A

E) None of these

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

A class is a(n) ________ that is defined by the programmer.
A) data type
B) function
C) method
D) attribute
E) None of these

A

Answer: A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q
  1. Assuming that Rectangle is a class name, the statement:
    Rectangle *BoxPtr;
    A) declares an object of class Rectangle
    B) assigns the value of *BoxPtr to the object Rectangle
    C) defines a Rectangle pointer variable called BoxPtr
    D) is illegal in C++
    E) None of these
A

Answer: C

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

A class may have this many default constructor(s).
A) only one
B) more than one
C) a maximum of two
D) any number
E) None of these

A

Answer: A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q
  1. C++ requires that a copy constructor’s parameter be a(n) ________.
    A) integer data type
    B) floating point data type
    C) pointer variable
    D) reference object
    E) None of these
A

Answer: D

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

When objects contain pointers, it is a good idea to create an explicit ________ function.
A) destructor
B) copy constructor
C) static constructor
D) inline constructor
E) None of these

A

Answer: B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

If you do not furnish one of these, an automatic memberwise copy will be performed when one object is
assigned to another object.
A) overloaded constructor function
B) overloaded assignment operator
C) default constructor function
D) overloaded copy operator
E) None of these

A

Answer: B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

If a member variable is declared ________, all objects of that class have access to that variable.
A) static
B) dynamic
C) inline
D) default
E) None of these

A

Answer: A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

The beginning of a function template is marked by a ________.
A) return type
B) parameter list
C) template prefix
D) semicolon
E) None of these

A

Answer: C

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

The list container provided by the Standard Template Library is a template version of a ________.
A) singly-linked list
B) doubly-linked list
C) circular-linked list
D) backward-linked list
E) None of these

A

Answer: B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

The advantage a linked list has over a vector is:
A) A linked list can dynamically shrink or grow, and a vector cannot
B) A linked list is smaller than a vector
C) A node can be inserted into or removed from a linked list faster than from a vector
D) Data removal and insertion are more accurate with a linked list than with a vector
E) None of these

A

Answer: C

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Variations of the linked list are:
A) doubly-linked list
B) circular linked list
C) backward linked list
D) A and B
E) None of these

A

Answer: D

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

inked list class must take care of removing the dynamically allocated nodes. This is done by ________.
A) the constructor function
B) the destructor function
C) overriding the removal function
D) overloading the memory persistence operator
E) None of these

17
Q

A dynamic stack has a ________ size, and is implemented as a(n) ________.
A) variable, linked list
B) fixed, linked list
C) variable, array
D) fixed, array
E) None of these

18
Q

The following statement:
stack< int, vector<int> > iStack;
indicates:
A) a new stack of integers, implemented as a vector
B) a new stack of integers, implemented as a deque
C) a new stack named vector, implemented as integers
D) a new vector named stack, implemented with integers
E) None of these</int>

19
Q

________ queues are more intuitive and easier to understand than ________ queues.
A) Static, dynamic
B) Dynamic, static
C) Deque-like, stack-like
D) Stack-like, deque-like
E) None of these

20
Q

f a recursive function does not contain a base case, it ________.
A) returns 0 and stops
B) returns false and stops
C) uses up all available stack memory, causing the program to crash
D) reaches the recursive case and stops
E) None of these

21
Q

When function A calls function B, which in turn calls function A, this is known as:
A) direct recursion
B) indirect recursion
C) function swapping
D) perfect recursion
E) None of these

22
Q

A good reason to use the binary tree structure is:
A) to expedite the process of searching large sets of information
B) aesthetics and program design
C) code readability
D) it is more flexible than the Unary Tree structure
E) None of these

23
Q

When a binary tree is used to facilitate a search, it is referred to as a ________.
A) binary queue
B) binary ordered deque
C) binary search tree
D) sort algorithm
E) None of these

24
Q

The head pointer, anchored at the top of a binary tree, is called the ________.
A) root node
B) tree pointer
C) binary pointer
D) Either A or C
E) None of these

25
True/False: In a binary tree, each node must have a minimum of two children.
Answer: FALSE
26
True/False: The height of a tree describes how many levels there are in the tree.
Answer: TRUE
27
True/False: Binary trees are commonly used to organize key values that index database records.
Answer: TRUE
28
Write a recursive function called calcHarmonic that takes an integer n as an argument and returns a double. This function should calculate the series 1 + ½ + 1/3 + ¼ + ... 1/n. So for example, if called with calcHarmonic(5) it would return the value of 1 + ½ + 1/3 + ¼ + 1/5.
// CPP program to find sum of // harmonic series using recursion #include using namespace std; double calcHarmonic(int n) { // Base condition if (n < 2) return 1; else return 1 /static_cast(n) + (calcHarmonic (n - 1)); } // Driven Code int main() { cout << (calcHarmonic (8)) << endl; cout << (calcHarmonic (10)) << endl; return 0; }