PCAP Exam QuestionsBrowse all questions from this exam

PCAP Exam - Question 134


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

Show Answer
Correct Answer: BC

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

9 comments
Sign in to comment
macxszOptions: BC
Apr 30, 2022

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

NengggOptions: BC
Dec 11, 2022

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
Jan 27, 2024

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

dsirak
Aug 7, 2022

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

JnanadaOptions: BC
Aug 22, 2022

Correct answer should be B and C.

alfonsocav1982Options: BC
Aug 28, 2022

B and C are correct

halyOptions: BC
Oct 8, 2022

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

Damon54Options: BC
Feb 9, 2024

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

kstrOptions: AB
Feb 15, 2024

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
Feb 26, 2024

Sure ?!?