View Assessment Result: Multiple Choice Quiz 5



Your performance was as follows:

1.
Which of the following is true of inheritance?

(a) It is an important idea in Object Oriented Programming, but currently it is not implemented in C++.
(b) It protects data members from illegal access.
(c) It provides for the elegant construction of a new class from an existing class.
(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.
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



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

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

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



4.
All of the following are features of object-oriented programming EXCEPT

(a) inheritance
(b) encapsulation
(c) polymorphism
(d) garbage collection

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.
In which of the following situations would private inheritance be a sound choice?

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

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.
Which of the following is necessary in order to obtain polymorphic behavior in C++?

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



7.
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 available to be called by the user to prevent the destructor for the derived class from being called..
(d) It is called automatically.

Correct answer is (d)

Your score on this question is: 0.00

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



8.

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) Base::f(double) and Derived::f(int)
(d) Derived::f(int) and Derived::f(int)

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



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) unions
(b) casting of ints to floats and the use of a simple list
(c) templates
(d) inheritance

Correct answer is (d)

Your score on this question is: 0.00

Feedback:
   See section 1.5.1 of the course notes.
   (c) 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 only the list header, and not the nodes.
(c) It should copy the list header, but should copy the nodes only if there are less than four nodes.
(d) It should copy all the nodes and the list header.

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



Go to top of assessment.

Total score: 80.00