Question 145 of 511
Object-Oriented ProgrammingmediumMultiple SelectObjective-mapped

Quick Answer

The answer is that in diamond inheritance, the topmost base class is visited last. This is correct because Python’s Method Resolution Order (MRO) follows the C3 linearization algorithm, which ensures a consistent, monotonic search path through the inheritance hierarchy. The algorithm guarantees that a child class is always checked before its parents, and when multiple parent classes share a common ancestor, that ancestor is only visited after all its subclasses have been exhausted. On the Certified Associate Python Programmer PCAP exam, this concept often appears in multiple-choice questions testing your understanding of how Python resolves method calls in complex inheritance, with a common trap being the assumption that Python uses a simple depth-first search. A reliable memory tip is to remember the MRO mantra: “child before parent, and the topmost common ancestor comes last,” which you can verify at any time by inspecting a class’s `__mro__` attribute.

PCAP Object-Oriented Programming Practice Question

This PCAP practice question tests your understanding of object-oriented programming. Read the scenario carefully and evaluate each option against the stated constraints before committing to an answer. After answering, compare your reasoning against the explanation and wrong-answer breakdown below. Once you have made your selection, read the full explanation to reinforce the concept and understand why each distractor is designed to mislead on exam day.

Which three statements about the Method Resolution Order (MRO) in Python are true? (Choose three.)

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

The MRO can be viewed using the __mro__ attribute.

Option A is correct because every Python class has an `__mro__` attribute that returns a tuple of classes in the order they are searched for methods and attributes. This attribute is automatically generated by the C3 linearization algorithm and provides a clear, inspectable view of the resolution order.

Key principle: Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • The MRO can be viewed using the __mro__ attribute.

    Why this is correct

    Each class has a __mro__ attribute showing the order.

    Related concept

    Read the scenario before looking for a memorised answer.

  • MRO is determined by the C3 linearization algorithm.

    Why this is correct

    Python uses C3 linearization to compute MRO.

    Related concept

    Read the scenario before looking for a memorised answer.

  • The MRO is only used for methods, not attributes.

    Why it's wrong here

    MRO affects attribute lookup as well, since attributes are looked up in the same order.

  • In diamond inheritance, the topmost base class is visited last.

    Why this is correct

    C3 linearization ensures the common ancestor is visited after all derived classes.

    Related concept

    Read the scenario before looking for a memorised answer.

  • The MRO can be changed by modifying the class hierarchy at runtime.

    Why it's wrong here

    MRO is fixed when the class is defined; altering parent classes later does not change MRO.

Common exam traps

Common exam trap: answer the scenario, not the keyword

Python Institute often tests the misconception that the MRO only applies to methods, when in fact it governs all attribute lookups, including data attributes and descriptors.

Detailed technical explanation

How to think about this question

The C3 linearization algorithm ensures that subclasses appear before their parents and that the order respects monotonicity—if a class inherits from multiple parents, the MRO preserves the local precedence order of each parent class. In diamond inheritance (e.g., class D(B, C) where both B and C inherit from A), the MRO will visit A last, ensuring that the most specific implementation is used first and that the common base class is not visited multiple times.

KKey Concepts to Remember

  • Read the scenario before looking for a memorised answer.
  • Find the constraint that changes the correct option.
  • Eliminate answers that are true in general but not in this case.

TExam Day Tips

  • Watch for words such as best, first, most likely and least administrative effort.
  • Review why wrong options are wrong, not only why the correct option is correct.

Key takeaway

Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.

Real-world example

How this comes up in practice

A company's IT admin needs to give a contractor read-only access to production logs without sharing account credentials. Using role-based access control (RBAC) and temporary scoped permissions — not a permanent shared password — is the correct pattern. Questions like this test whether you can apply least-privilege access across cloud identity services.

What to study next

Got this wrong? Here's your next step.

Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.

Related practice questions

Related PCAP practice-question pages

Use these pages to review the topic behind this question. This is how one missed question becomes focused revision.

Practice this exam

Start a free PCAP practice session

Short sessions build daily habit. Longer sessions build exam-day stamina. Try a timed session to simulate real conditions.

FAQ

Questions learners often ask

What does this PCAP question test?

Object-Oriented Programming — This question tests Object-Oriented Programming — Read the scenario before looking for a memorised answer..

What is the correct answer to this question?

The correct answer is: The MRO can be viewed using the __mro__ attribute. — Option A is correct because every Python class has an `__mro__` attribute that returns a tuple of classes in the order they are searched for methods and attributes. This attribute is automatically generated by the C3 linearization algorithm and provides a clear, inspectable view of the resolution order.

What should I do if I get this PCAP question wrong?

Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.

What is the key concept behind this question?

Read the scenario before looking for a memorised answer.

About these practice questions

Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

Same concept, more angles

2 more ways this is tested on PCAP

These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.

Variation 1. Which THREE statements about the Python method resolution order (MRO) are true? (Select exactly 3.)

hard
  • A.The MRO is determined at runtime when a method is called.
  • B.The MRO of a class can be viewed using the __mro__ attribute.
  • C.C3 linearization is the algorithm used for MRO in Python 3.
  • D.Python uses a depth-first left-to-right algorithm for MRO.
  • E.super() uses the MRO to determine which method to call.

Why B: Option B is correct because the `__mro__` attribute on a class returns a tuple of classes in the exact order that Python uses to resolve methods and attributes. This attribute is computed at class definition time using the C3 linearization algorithm, and it provides a direct, read-only view of the resolution order for that class.

Variation 2. Refer to the exhibit. What is the output? (Note: actual MRO may vary; choose the one that matches Python 3 C3 linearization.)

hard
  • A.(<class '__main__.D'>, <class '__main__.B'>, <class '__main__.C'>, <class '__main__.A'>)
  • B.(<class '__main__.D'>, <class '__main__.B'>, <class '__main__.C'>, <class '__main__.A'>, <class 'object'>)
  • C.(<class '__main__.D'>, <class '__main__.C'>, <class '__main__.B'>, <class '__main__.A'>, <class 'object'>)
  • D.(<class '__main__.D'>, <class '__main__.A'>, <class '__main__.B'>, <class '__main__.C'>, <class 'object'>)

Why B: Option B is correct because Python 3 uses C3 linearization to compute the Method Resolution Order (MRO). For class D inheriting from B and C, which both inherit from A, the MRO is D, B, C, A, object. This satisfies the monotonicity and local precedence order: B comes before C (as per D's bases), and A is last among the user-defined classes, with object always appended.

Keep practising

More PCAP practice questions

Last reviewed: Jun 30, 2026

Question Discussion

Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.

Loading comments…

Sign in to join the discussion.

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.