PCAP Object-Oriented Programming Practice Question
Exhibit
$ cat abstract_example.py
from abc import ABC, abstractmethod
class Shape(ABC):
@abstractmethod
def area(self):
pass
class Circle(Shape):
def __init__(self, radius):
self.radius = radius
$ python3 -c "from abstract_example import Circle; c = Circle(5)"Refer to the exhibit. What happens when the last command is executed?
⚠ Common exam trap
The Python Institute's PCAP exam often tests the distinction between `TypeError` for abstract class instantiation and `AttributeError` for missing attributes on an existing object, trapping candidates who confuse the timing of the error (instantiation vs. method call).
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
✓
It raises TypeError: Can't instantiate abstract class Circle with abstract methods area
The last command attempts to instantiate an abstract class `Circle` that has an abstract method `area` which has not been implemented. In Python, abstract classes defined with `ABC` and decorated with `@abstractmethod` cannot be instantiated directly; attempting to do so raises `TypeError` with the message 'Can't instantiate abstract class Circle with abstract methods area'.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
It creates a Circle object successfully
Why it's wrong here
Instantiating Circle successfully would require every method marked @abstractmethod on the class to be overridden with a concrete implementation. Because the exhibit never provides an implementation for area, Circle remains an abstract class, and the ABCMeta machinery explicitly forbids creating instances of it. Thus no Circle object is ever constructed, so this option is incorrect.
- ✗
It prints nothing and exits with code 0
Why it's wrong here
This option assumes execution completes normally and the process returns a successful zero exit code. In reality, the instantiation line triggers an uncaught TypeError inside the abstract class check, so Python prints a full traceback and exits with a non-zero status. Since the exception is never handled, the program cannot silently print nothing and finish cleanly.
- ✓
It raises TypeError: Can't instantiate abstract class Circle with abstract methods area
Why this is correct
When a class inherits from ABC and contains an @abstractmethod, Python's ABCMeta checks at instantiation time whether any abstract methods remain unimplemented. Because Circle defines area as abstract and the exhibit does not override it, calling Circle() raises TypeError: Can't instantiate abstract class Circle with abstract methods area. This exactly reflects the intended behavior of the abc module, making this option correct.
- ✗
It raises AttributeError: 'Circle' object has no attribute 'area'
Why it's wrong here
An AttributeError would only be raised after a Circle instance already existed and code attempted to access a missing area attribute. But the @abstractmethod declaration prevents the object from ever being created: the failure occurs during the type's __new__ check, before any attribute lookup on an instance could happen. Therefore no Circle object exists to trigger an AttributeError, so this option is incorrect.
Go deeper
Related to this question
About these practice questions
Courseiva writes every PCAP question from scratch — 421 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or 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.