nerdexam
Python_Institute

PCPP-32-101 · Question #53

If inheritance can result in MRO inconsistency, should you stop using inheritance altogether and make use of polymorphism instead?

The correct answer is B. No, because inheritance does not contradict polymorphism - there is always the possibility to gain. Inheritance and polymorphism are complementary concepts; MRO inconsistencies can often be resolved by redesigning the inheritance hierarchy rather than abandoning inheritance altogether.

Advanced OOP

Question

If inheritance can result in MRO inconsistency, should you stop using inheritance altogether and make use of polymorphism instead?

Options

  • AYes, because polymorphism is a faster way to achieve the same solution, and it is lighter due to
  • BNo, because inheritance does not contradict polymorphism - there is always the possibility to gain
  • CYes, because in more complex projects it is the only way to manage complex inheritance
  • DNo, because polymorphism means complex relations between classes as it gives no control for

How the community answered

(22 responses)
  • A
    5% (1)
  • B
    68% (15)
  • C
    9% (2)
  • D
    18% (4)

Explanation

Inheritance and polymorphism are complementary concepts; MRO inconsistencies can often be resolved by redesigning the inheritance hierarchy rather than abandoning inheritance altogether.

Topics

#MRO#multiple inheritance#polymorphism#inheritance design

Community Discussion

No community discussion yet for this question.

Full PCPP-32-101 Practice