Public Inheritance - Quiz Explanation

The correct answers are indicated below, along with text that explains the correct answers.

 
1. The inheritance mechanism provides a means of deriving:
  A. a new class from an existing class
  B. a new operator from an existing operator
  C. a new set of memory allocation functions from the built-in ones
  D. all of these
  The correct answer is A.
Inheritance is a means of reusing code effectively. To derive a new operator from an existing operator or to derive a new set of memory allocation functions from the built-in ones is called operator overloading.

2. The ___________ member function is declared in the base class but redefined in the derived class.
  A. class
  B. overloaded
  C. virtual
  D. operator
  The correct answer is C.
Redefining virtual functions is called overriding as opposed to overloading.

3. Public inheritance hierarchies allow:
  A. code reuse
  B. subtyping
  C. virtual function overriding
  D. all of these
  The correct answer is D.
All of these are allowed by public inheritance.

4. Which is not a C++ access keyword?
  A. public
  B. private
  C. privileged
  D. protected
  The correct answer is C.
Privileged is not a C++ access keyword.

5. In public inheritance:
  A. all members of the base class are inherited and are made public
  B. members of the base class that are not private are inherited and retain their access types
  C. all members of the base class are inherited and retain their access types
  D. only public members of the base class are inherited and they remain public
  The correct answer is B.
In public inheritance, members of the base class that are not private are inherited and retain their access types.