View Assessment Result: Multiple Choice Quiz 5



Your performance was as follows:

1.
Which of the following is true of multiple inheritance?

(a) It provides for the elegant construction of a new class from existing classes.
(b) It causes one type to behave like several types.
(c) It is an important idea in Object-Oriented Programming, but currently it is not implemented in C++.
(d) It allows the application of inheritance over and over, producing deep hierarchies.

Correct answer is (a)

Your score on this question is: 10.00

Feedback:
   See section 1.5.1 of the course notes.
   (a) No Feedback



2.
Polymorphism is a mechanism that is used in order to

(a) determine methods of a class based on its data members
(b) protect data members from illegal access
(c) build new classes on top of existing ones
(d) determine the type of an object dynamically at run time

Correct answer is (d)

Your score on this question is: 10.00

Feedback:
   See section 1.5.1 of the course notes.
   (d) No Feedback



3.
Inheritance is an important feature of C++ because

(a) it can often replace templates
(b) it makes type-checking much easier
(c) it greatly increases efficiency
(d) it is a powerful code reuse mechanism

Correct answer is (d)

Your score on this question is: 10.00

Feedback:
   See section 1.5.1 of the course notes.
   (d) No Feedback



4.
Which of the following is necessary in order to obtain polymorphic behavior in C++?

(a) Multiple inheritance is avoided.
(b) Templates are avoided.
(c) Only instances of the base class are used.
(d) Pointers or references are used with virtual functions.

Correct answer is (d)

Your score on this question is: 10.00

Feedback:
   See section 1.5.1 of the course notes.
   (d) No Feedback



5.

Consider the following inheritance declarations.

      class Base    { public: int x; private int y; };
      class Derived: public Base  { public: int z; };
      Derived  D;

Under these declarations, which of the following statements, if any, will fail to compile?



(a) D.x = 555;
(b) D.y = 555;
(c) D.z = 555;
(d) None

Correct answer is (b)

Your score on this question is: 10.00

Feedback:
   See section 1.5.1 of the course notes.
   (b) No Feedback



6.

Consider the following inheritance declarations.

    class Base { virtual  void f(int); virtual void f(float); };
    class Derived: public Base  { void f(int); };
    Derived  D;
    Base     B, *p = &D;

In the context of these declarations, the two functions that are used in the two calls D.f(3.1415); and p-f(3.1415); are, respectively,



(a) Base::f(double) and Base::f(double)
(b) Derived::f(int) and Base::f(double)
(c) Derived::f(int) and Derived::f(int)
(d) Base::f(double) and Derived::f(int)

Correct answer is (c)

Your score on this question is: 10.00

Feedback:
   See section 1.5.1 of the course notes.
   (c) No Feedback



7.
The purpose of initializers in a constructor is to

(a) make it easier to implement value semantics
(b) make sure all data members are initialized
(c) avoid assignments and use copy constructors directly
(d) avoid the copy constructor

Correct answer is (c)

Your score on this question is: 10.00

Feedback:
   See section 1.5.1 of the course notes.
   (c) No Feedback



8.
Every class that is supposed to behave like a built-in type must overload which operator?

(a) The output operator
(b) The comma operator
(c) The call operator
(d) The assignment operator

Correct answer is (a)

Your score on this question is: 10.00

Feedback:
   See section 1.5.1 of the course notes.
   (a) No Feedback



9.
The proper tool for writing an array class whose instances can have some elements with ints and other elements with floats is the use of

(a) templates
(b) unions
(c) casting
(d) inheritance

Correct answer is (a)

Your score on this question is: 0.00

Feedback:
   See section 1.5.1 of the course notes.
   (d) No Feedback



10.
How should a copy constructor function in a linked list class?

(a) A linked list class should not have a copy constructor.
(b) It should copy the list header, but should copy the nodes only if there are less than four nodes.
(c) It should copy all the nodes and the list header.
(d) It should copy only the list header, and not the nodes.

Correct answer is (c)

Your score on this question is: 10.00

Feedback:
   See section 1.5.1 of the course notes.
   (c) No Feedback



Go to top of assessment.

Total score: 90.00