Courseiva
Object-Oriented ProgrammingeasyMultiple ChoiceObjective-mapped

PCAP Object-Oriented Programming Practice Question

A developer defines a class with an __init__ method that sets instance attributes. Which of the following is the correct way to call the parent class's __init__ from a child class?

⚠ Common exam trap

The PCAP exam often tests the misconception that `super()` requires explicit arguments or that calling the parent class directly by name (e.g., `Parent.__init__(self, ...)`) is the standard or recommended approach, when in fact `super().__init__(...)` is the Pythonic way and is required for proper MRO handling in complex hierarchies.

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

super().__init__(arg1, arg2)

`super().__init__(arg1, arg2)` is the modern, recommended way to call the parent class's `__init__` method in Python. It uses the `super()` function without arguments to automatically resolve the parent class based on the method resolution order (MRO), ensuring proper cooperative multiple inheritance and avoiding hardcoding the parent class name.

Answer analysis

Option-by-option breakdown

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

  • super(self, Child).__init__(arg1, arg2)

    Why it's wrong here

    super(self, Child).__init__() is invalid because super() expects a class as its first argument and an instance as its second, i.e., super(Child, self). Here the arguments are reversed, so self (an instance) is passed as the class, which raises a TypeError. In Python 3, the zero-argument super() form is preferred and makes this whole issue moot.

  • Parent.__init__(self, arg1, arg2)

    Why it's wrong here

    Parent.__init__(self, arg1, arg2) technically initializes the parent, but it hard-codes the class name and bypasses the method resolution order (MRO). In a multiple-inheritance scenario, this can skip other classes that should be initialized and may cause a shared base to be initialized multiple times, leading to inconsistent state. The recommended alternative is super().__init__(arg1, arg2), which follows the MRO.

  • Child.__init__(self, arg1, arg2)

    Why it's wrong here

    Child.__init__(self, arg1, arg2) inside the child's own __init__ is an unconditional recursive call with no terminating condition. It calls the same method again rather than a parent method, so execution will re-enter the method indefinitely until Python raises a RecursionError. This is not a delegation to the parent; it is a self-call, and the fix is to use super().__init__(arg1, arg2).

  • super().__init__(arg1, arg2)

    Why this is correct

    super().__init__(arg1, arg2) is the idiomatic Python 3 way to invoke the parent initializer. The zero-argument super() call automatically captures the current class and instance via the compiler's __class__ cell, returning a proxy that resolves to the next class in the MRO. This preserves cooperative multiple inheritance, ensuring that each class in the hierarchy is initialized correctly and that diamond dependencies are handled safely.

Visual reference

Client Recursive Resolver Root DNS (13 root servers) TLD DNS (.com, .org, …) Authoritative example.com query IP addr answer

About these practice questions

This PCAP question is part of Courseiva's 169-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 →

How Courseiva writes practice questions · Editorial policy

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.