PCAP Object-Oriented Programming Practice Question
Given: class A: def method(self): print('A'); class B(A): def method(self): super().method(); print('B'); class C(A): def method(self): super().method(); print('C'); class D(B, C): pass. What is printed by D().method()?
⚠ Common exam trap
Python Institute often tests the misconception that super() always calls the immediate parent class (A) in a linear chain, rather than following the full MRO, leading candidates to pick 'A B C' instead of the correct 'A C B'.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
A C B
Python's MRO (Method Resolution Order) for class D, which inherits from B and C (both inheriting from A), follows the C3 linearization algorithm. The MRO for D is D -> B -> C -> A, so calling D().method() triggers B.method(), which calls super().method() (resolving to C.method()), which calls super().method() (resolving to A.method()), printing 'A', then back to C prints 'C', then back to B prints 'B', resulting in 'A C B'.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
A B C
Why it's wrong here
The MRO is D, B, C, A, so A prints first, then C, then B. Printing A, B, C ignores C's position between B and A, which would require C to inherit from B rather than sharing base A.
- ✓
A C B
Why this is correct
The MRO for D is D, B, C, A, so `super()` inside B resolves to C, not A. B's `super().method()` therefore invokes C's method, which prints 'C' after its own `super()` call reaches A and prints 'A'. Control then returns to B, printing 'B', yielding A C B.
- ✗
C A B
Why it's wrong here
C's super() call reaches A before B runs, so C cannot print before A. This ordering would arise only if C were listed first in D's bases, placing C ahead of B in the MRO.
- ✗
B A C
Why it's wrong here
Python's MRO for D(B, C) is D, B, C, A, so super() chains print A, C, B. This ordering reverses C and B, which would only occur if C preceded B in the MRO — impossible given D's declared base order.
Visual reference
Go deeper
Related to this question
About these practice questions
This PCAP question is part of Courseiva's 421-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This PCAP practice question is part of Courseiva's free Python Institute certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the PCAP exam.