1. Home
  2. Computer Science MCQs
  3. C++ and Object-Oriented Programming
  4. What relationship does public inheritance from a base…

Added 30 Nov -0001

What relationship does public inheritance from a base class represent in C++?

  1. A uses-a relationship, where the base is a local variable
  2. A copies-a relationship, duplicating the base layout
  3. An is-a relationship, where the derived type specialises the base Correct answer
  4. A has-a relationship, where the base object is held as a member of the class

Correct answer

C. An is-a relationship, where the derived type specialises the base

14 views

MCQSEXAM

Explanation

Public inheritance expresses is-a: a derived object can be used wherever a base object is expected, which is what makes polymorphism through base pointers valid. Composition, where the base is a member object, models has-a and is usually preferred when the relationship is not a genuine specialisation. Private inheritance makes the base an implementation detail and does not expose the is-a conversion publicly.

Reference

Asked in: NTS, PPSC IT, Campus Interviews

Preparing for an exam?

Doubts & discussion

Not sure why the answer is C? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More C++ and Object-Oriented Programming MCQs

Practise all C++ and Object-Oriented Programming MCQs

Similar MCQs