Exam PCAP All QuestionsBrowse all questions from this exam
Question 134

Assuming that the following inheritance set is in force, which of the following classes are declared properly? (Choose two.)

    Correct Answer: B, C

    The correct class declarations are those that do not create inconsistencies with the method resolution order (MRO) given the inheritance hierarchy. 'class Class_4(C,B): pass' is correct because both C and B ultimately inherit from A and do not cause any MRO conflict. Similarly, 'class Class_1(D): pass' is valid because D inherits from both B and C, which eventually leads back to A, maintaining a proper MRO. Other options like 'class Class_3(A,C): pass' and 'class Class_2(A,B): pass' would result in a TypeError due to MRO conflicts.

Discussion
macxszOptions: BC

Correct answers: B. class Class_4(C,B): pass C. class Class_1(D): pass

NengggOptions: BC

A and D will have MRO error, it should be A. class Class_3(C,A): pass D. class Class_2(B,A): pass

seaverickOptions: BC

class A: pass class B(A): pass class C(A): pass class D(B,C): pass #class Class_3(A,C): pass #TypeError: Cannot create a consistent method resolution order (MRO) for bases A, C class Class_4(C,B): pass class Class_1(D): pass #class Class_2(A,B): pass #TypeError: Cannot create a consistent method resolution order (MRO) for bases A, B Ans is B,C

kstrOptions: AB

A. class Class_3(A,C): pass This class declaration is proper based on the assumed inheritance set. It correctly inherits from classes A and C. B. class Class_4(C,B): pass This class declaration is also proper based on the assumed inheritance set. It correctly inherits from classes C and B. C. class Class_1(D): pass This class declaration is not proper based on the assumed inheritance set. It tries to inherit from class D, but D doesn't exist in the assumed inheritance set. D. class Class_2(A,B): pass This class declaration is not proper based on the assumed inheritance set. It tries to inherit from classes A and B, which is fine, but it doesn't cover all the necessary classes in the inheritance set (specifically, class C and its descendants). So, the proper class declarations are: A. class Class_3(A,C): pass B. class Class_4(C,B): pass

Damon54

Sure ?!?

Damon54Options: BC

A. class Class_3(A,C): pass, it does not work because if the variable or method is not found in A it will not even be found in C as C inherits from A D. class Class_2(A,B): pass, the same thing doesn't work because if the variable or method is not found in A it won't even be found in B as B inherits from A

halyOptions: BC

B and C are correct because you cant invoke a parent class first

alfonsocav1982Options: BC

B and C are correct

JnanadaOptions: BC

Correct answer should be B and C.

dsirak

I also agree, B and C are correct. Switch to voting comment, so that Community vote distribution is displayed after Reveal Solution.