Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

13. If a base class pointer, p , points to a derived class instance, and both base and derived classes have a method void doIt()

13.

If a base class pointer, p, points to a derived class instance, and both base and derived classes have a method void doIt() which takes no parameters, then p->doIt() will invoke the derived class version ...:

A.

... only if both the base class method and the derived class method are declared virtual.

B.

...if the derived class method is declared virtual, but the base is not declared virtual.

C.

... if the base class method is declared virtual, even if the derived class method is not declared virtual.

14.

Consider the boolean expression (where XOR is the exclusive-or operator defined in the modules or throughout the internet):

(P OR Q) XOR (P AND Q)

Check the (one) true statement.

A.

This expression is equivalent to the simpler expression

P AND Q

B.

This expression cannot be simplified to any of the options, above.

C.

This expression is equivalent to the simpler expression

P OR Q

D.

This expression is equivalent to the simpler expression

P XOR Q

15.

Lazy Deletion, as we have implemented it in a general tree, is good for ...

(Check all that apply.)

A.

... conserving memory.

B.

... fast removal.

C.

... fast insertion.

D.

... avoiding garbage collection for a small number of removal calls.

16.

Bob defines a base class, Base, with instance method func(), but does not declare it to be virtual.

Alicia (who has no access to Bob's source code) defines three derived classes, Der1, Der2 and Der3, of the base class and overrides func().

Ying has no access to Bob or Alicia's source code and does not know anything about the derived classes, including their names or how many derived classes exist. Ying does know about the Base class and knows about its public instance function func(). She is also aware that there may be derived classes that overridefunc().

Ying uses a Base pointer, p, to loop through a list of Base object pointers. Ying is aware that the list pointers may point to Base objects or some subclass objects of Base.

Check all that apply.

A.

Since Ying's loop pointer, p, is type Base, no compiler error will occur.

B.

Ying can call p->func() on each object in the loop (no coercion) and will always get the Base behavior of this function.

C.

Ying can call p->func() on each object in the loop and get distinct behavior as defined by the object pointed to if she uses type coercion to assist her.

D.

Ying can call p->func() on each object in the loop and get no compiler error.

E.

Ying can call p->func() on each object in the loop and get distinct behavior as defined by the object pointed to.

17.

If a Boolean function does not have a simple algebraic or logical description then it is most easily implemented by a method that has which of the following?

A.

Several user input statements with appropriate prompts to the user.

B.

A statement that uses multiplication and division.

C.

A long if statement.

D.

A for loop.

E.

An array.

18.

Assume p is a private pointer member of class DeepClass that gets assigned dynamically allocated data in one or more of DeepClass's instance methods. p controls this dynamically allocated memory.

Check all that apply to the client statement myDeepB = myDeepA; between two DeepClass objects.

A.

The default assignment operator that C++ provides will result in a compiler error.

B.

The default assignment operator that C++ provides will cause both myDeepA's and myDeepB's "p-controlled" memory be to simultaneously modified if myDeepA's is used to modify its copy of that memory (say, immediately after the assignment statement).

C.

The default assignment operator that C++ provides will immediately crash the program when the assignment statement is encountered during run-time.

D.

If DeepClass has a user-defined destructor that deallocates p's memory, but no overloaded assignment operator is provided, then the assignment statement, followed immediately by both objects going out-of-scope (as in the program or method in which both objects are defined, ending), will cause a run-time err

E.

The default assignment operator that C++ provides will result the dynamically allocated memory to be duplicated and copied over to myDeepB.

19.

The following are advantages of a linked-list over an an array:

(Check all that apply.)

A.

Even if we don't have a pointer to the proper node, a linked-list can easily access any element in the middle of the list with a single statement, but an array requires a loop to gain access to that node.

B.

A linked-list takes less memory to store a single element (a Node in the list) than an array takes to store its version of a single element (the kth item in the array).

C.

Inserting an item into an already-ordered linked-list, so as to preserve the order, requires fewer loops and/or a shorter loop than inserting an item into an ordered array so as to preserve the order.

D.

Assuming we have a pointer to the proper node, a linked-list will enable fast insertion into the middle of the list, while insertion into the middle of an array, even if we know the int index of the desired insertion point, will not be as fast or simple.

20.

A Boolean function that has four inputs and one output. The programmer decides to implement it using an array of type bool. How many elements (what size array) gives the programmer the maximum flexibility in defining the function?

A.

3

B.

4

C.

16

D.

15

E.

8

21.

Overloading the assignment operator can be done so that obj = x; can be valid, even if x is in a different class than obj.

True

False

22.

If p is a pointer member of class DeepClass that gets assigned dynamically allocated data in one or more of DeepClass's instance methods then the memory to which p controls is considered to be technically "part of the DeepClass objects."

True

False

23.

Consider the following statement:

ifstream galSource("galaxyData.txt");

Check the true statements (there may be more than one):

A.

If the file is successfully opened, and it is a plain text file, then we would use the statement getLine(galSource, someStringVar); to read a line from it.

B.

It attempts to open a file named "galaxyData.txt" for reading/input.

C.

It attempts to open a file named "galaxyData.txt" for writing/output.

D.

If the file it wants to access has too restrictive permissions, as set by the file owner or administrator, then the variable galSource will be assigned the value = NULL (i.e., 0).

E.

It attempts to open a file named "galSource" for reading/input.

F.

If the file is successfully opened, and it is a plain text file, then we would use the statement getLine(cin, someStringVar); to read a line from it.

G.

If the file it wants to access is not in the executable path (usually the same director as the program), then the variable galSource will be assigned the value = -1.

24.

Match the concept with the phrase that best describes it.

Choices - use a choice only once

A.

A Linked List data structure

B.

Stack data Structure

C.

A Queue data structure

D.

A simple Array

Match each of the following to a choice

1.

... typically uses dynamic allocation and its size grows or shrinks as needed.

Select

A.

A Linked List data structure

B.

Stack data Structure

C.

A Queue data structure

D.

A simple Array

2.

... is first-in, first-out (FIFO)

Select

A.

A Linked List data structure

B.

Stack data Structure

C.

A Queue data structure

D.

A simple Array

3.

... uses push() and pop() methods to access the data.

Select

A.

A Linked List data structure

B.

Stack data Structure

C.

A Queue data structure

D.

A simple Array

4.

... allows fast random access to the data elements.

Select

A.

A Linked List data structure

B.

Stack data Structure

C.

A Queue data structure

D.

A simple Array

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts of Database Management

Authors: Philip J. Pratt, Mary Z. Last

8th edition

1285427106, 978-1285427102

More Books

Students also viewed these Databases questions