View Assessment Result: Multiple Choice Quiz 5



Your performance was as follows:

1.
Which of the following is true of inheritance?

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



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.
What is composition?

(a) It is the same as polymorphism.
(b) It is a method to build new classes on top of existing ones.
(c) It is the inclusion of one class in another as a data member.
(d) It is an important idea in Object Oriented Programming, but currently it is not implemented in C++.

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



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

(a) polymorphism
(b) encapsulation
(c) garbage collection
(d) 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



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

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

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



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

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

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

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.

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) Derived::f(int) and Base::f(double)
(b) Base::f(double) and Derived::f(int)
(c) Base::f(double) and Base::f(double)
(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 purpose of initializers in a constructor is to

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

Correct answer is (c)

Your score on this question is: 0.00

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



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

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

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



Go to top of assessment.

Total score: 80.00