PCAP Object-Oriented Programming Practice Question
An engineer is debugging an application that uses inheritance. The base class 'Vehicle' defines a method 'start()' that prints 'Vehicle started'. The subclass 'Car' overrides 'start()' to print 'Car started'. The code contains a function that accepts a Vehicle object and calls 'start()'. What is the output if a Car object is passed?
⚠ Common exam trap
Python Institute often tests the misconception that the declared parameter type (Vehicle) determines which method runs, leading candidates to pick 'Vehicle started', when in fact Python always uses the actual object's type at runtime.
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
✓
'Car started'
When a Car object is passed to a function expecting a Vehicle reference, Python uses dynamic dispatch (late binding) to call the overridden `start()` method defined in the Car class. Since the actual runtime type is Car, the overridden version executes, printing 'Car started'. This is a fundamental principle of polymorphism in Python.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
'Car started Vehicle started'
Why it's wrong here
This output would be produced only if Car's start() override explicitly called super().start() after printing 'Car started'. The provided override makes no super call, so Python executes only the derived class implementation. Consequently, the base class message is never emitted, making this combined output impossible.
- ✗
'Vehicle started'
Why it's wrong here
This output would appear if Python used static dispatch based on a variable's declared type, or if Car did not override start(). However, Car does override the method, and Python resolves methods dynamically using the actual runtime type of the object. The instance is a Car, so its own start() is invoked and the Vehicle version is shadowed and never run.
- ✓
'Car started'
Why this is correct
Python's method resolution order searches the class hierarchy from the most derived class to the base, so for a Car instance, Car.start() is located first. That overridden method executes and prints exactly 'Car started'. The base implementation is overridden and not called unless the derived method explicitly delegates to it via super(), which it does not do here.
- ✗
AttributeError
Why it's wrong here
AttributeError occurs when an attribute or method does not exist anywhere in the object's class hierarchy. Here, Car inherits from Vehicle, which defines start(), and Car also provides its own override, so the method is definitely present. The call to instance.start() is completely valid, and no such exception is raised.
Go deeper
Related to this question
About these practice questions
One of 421 original PCAP practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. 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.