Quiz: Inheritance

To View Tricks: Login Required

Number of Questions: 20

Question: 1 -

When the inheritance is private, the private methods in base class are __________ in the derived class.

Options:
  1. Public

  2. Inaccessible

  3. Protected

  4. Accessible

  5. Answer:

    Inaccessible

    Solution:

     When the inheritance is private, the private methods in base class are inaccessible in the derived class


Question: 2 -

Inheritance allow in C++ Program?

Options:
  1. Class Re-usability

  2. Creating a hierarchy of classes

  3. All of the above

  4. Extendibility

  5. Answer:

    All of the above

    Solution not available.

Question: 3 -

What is meant by multiple inheritance?

Options:
  1. Deriving a derived class from more than one base class

  2. Deriving a base class from derived class

  3. None of the mentioned

  4. Deriving a derived class from base class

  5. Answer:

    Deriving a derived class from more than one base class

    Solution not available.

Question: 4 -

What will be the order of execution of base class constructors in the following method of inheritance.class a: public b, public c {...};

Options:
  1. c(); b(); a();

  2. b(); a(); c();

  3. a(); b(); c();

  4. b(); c(); a();

  5. Answer:

    b(); c(); a();

    Solution not available.

Question: 5 -

Which design patterns benefit from the multiple inheritances?

Options:
  1. Adapter and observer pattern

  2. Code pattern

  3. None of the mentioned

  4. Glue pattern

  5. Answer:

    Adapter and observer pattern

    Solution:

    A template is a formula for creating a generic class