QuestionQ37

Object-Oriented Programming

Assuming the following inheritance hierarchy is in effect, which classes are declared correctly?

Question Image

Choose two
  • A class Class_2(A,B): pass
  • B class Class_3(A,C): pass
  • C class Class_1(D): pass
  • D class Class_4(C,B): pass
Explanation

Python cannot create a consistent method-resolution order when a class lists a superclass before one of that superclass’s subclasses. A class can inherit from D directly, and it can inherit from the sibling classes C and B because their shared base A can be ordered after both.

Community Discussion

No comments yet. Be the first to start the discussion!