View Assessment Result: Multiple Choice Quiz 5



Your performance was as follows:

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

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

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



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

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

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



3.
In which of the following situations would private inheritance be a sound choice?

(a) To derive a numerical array class from a general one
(b) When the base class is templated
(c) Whenever multiple inheritance is used
(d) To derive a stack from a general linked list class

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) Templates are avoided.
(b) Only instances of the base class are used.
(c) Pointers or references are used with virtual functions.
(d) Multiple inheritance is avoided.

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



5.
Under what circumstances will a member function in C++ display polymorphic behavior?

(a) Always
(b) If and only if the class is not templated
(c) If and only if the function is explicitly declared to be virtual
(d) If and only if the class has multiple inheritance

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



6.
What is the role of the destructor for the base class when an instance of a derived class goes out of scope?

(a) It will not be called and it cannot be called at such a time.
(b) It must be called by the user, unless the derived class uses dynamic memory (the heap).
(c) It is called automatically.
(d) It is available to be called by the user to prevent the destructor for the derived class from being called..

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.

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



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

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

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



9.
The proper tool for writing a linked list that can have some elements with ints and other elements with floats is the use of

(a) inheritance
(b) templates
(c) unions
(d) casting of ints to floats and the use of a simple list

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



10.
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) inheritance
(b) templates
(c) casting
(d) unions

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



Go to top of assessment.

Total score: 100.00