Question 166 of 511
Object-Oriented ProgrammingeasyMultiple ChoiceObjective-mapped

Quick Answer

The answer is to manually call Vehicle.__init__(self) inside Car.__init__. This is correct because in Python, when a subclass overrides the __init__ method, the parent class’s __init__ is not automatically invoked—unlike some other languages. The subclass __init__ calling parent __init__ manually is the only way to ensure that inherited attributes like speed are properly initialized before adding subclass-specific ones like fuel_type. On the Certified Associate Python Programmer PCAP exam, this question tests your understanding of Python’s inheritance mechanics and the fact that overriding __init__ breaks the automatic chain. A common trap is assuming the parent’s __init__ runs automatically, leading to AttributeError when accessing speed. Remember the mnemonic: “Override breaks the chain—call parent to maintain the gain.”

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.

A developer is building a simulation of different types of vehicles. They have a base class Vehicle with an attribute speed initialized in __init__. They also have a subclass Car that inherits from Vehicle and adds an attribute fuel_type. The developer wants to ensure that every time a Car object is created, it also initializes the speed attribute from the Vehicle class. Which approach should the developer use?

Question 1easymultiple choice
Full question →

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

In Car.__init__, call Vehicle.__init__(self) manually.

Option B is correct because in Python, when a subclass overrides __init__, the parent class's __init__ is not automatically called. To ensure the speed attribute from Vehicle is initialized, the developer must explicitly call Vehicle.__init__(self) inside Car.__init__. This is a fundamental requirement of Python's inheritance mechanism for proper initialization of inherited attributes.

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.

  • Override the __new__ method of Vehicle.

    Why it's wrong here

    Overriding __new__ is not the standard way to ensure parent initialization.

  • In Car.__init__, call Vehicle.__init__(self) manually.

    Why this is correct

    This ensures the parent's __init__ executes, initializing speed.

    Related concept

    Read the scenario before looking for a memorised answer.

  • Use the @staticmethod decorator for initialization.

    Why it's wrong here

    Static methods do not participate in instance initialization.

  • In Car.__init__, define speed directly without calling parent's __init__.

    Why it's wrong here

    This duplicates code and ignores the inheritance hierarchy.

Common exam traps

Common exam trap: answer the scenario, not the keyword

Python Institute often tests the misconception that subclass __init__ automatically calls the parent __init__, leading candidates to incorrectly assume no explicit call is needed or to choose a wrong option like D.

Detailed technical explanation

How to think about this question

Under the hood, Python's method resolution order (MRO) ensures that Vehicle.__init__ is found via the class hierarchy when called explicitly. A subtle behavior is that if Vehicle.__init__ required additional parameters, the developer would need to pass them correctly; failing to do so raises a TypeError. In real-world scenarios, such as complex class hierarchies with multiple inheritance, using super() is often preferred over manually naming the parent class to avoid diamond problem issues and to maintain DRY code.

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 media company stores terabytes of video archives that are accessed once a year for audit purposes. Moving these objects to a cold storage tier (Azure Archive, S3 Glacier, or Google Nearline) costs a fraction of hot storage. Questions like this test whether you understand storage tiers, access frequency tradeoffs, and retrieval latency requirements.

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: In Car.__init__, call Vehicle.__init__(self) manually. — Option B is correct because in Python, when a subclass overrides __init__, the parent class's __init__ is not automatically called. To ensure the speed attribute from Vehicle is initialized, the developer must explicitly call Vehicle.__init__(self) inside Car.__init__. This is a fundamental requirement of Python's inheritance mechanism for proper initialization of inherited attributes.

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

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.