PCAP Object-Oriented Programming Practice Question
Which THREE of the following are characteristics of Python's special methods (dunder methods)? (Select exactly three.)
⚠ Common exam trap
Python Institute often tests the misconception that all dunder methods are automatically inherited or that they cannot be added dynamically, so candidates mistakenly select option C or D without realizing that Python's data model only provides defaults for a minimal set and allows runtime assignment to classes.
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
✓
They enable operator overloading for user-defined classes.
Special methods like `__add__` and `__eq__` allow user-defined classes to redefine the behavior of operators such as `+` and `==`. When Python encounters an operator expression, it looks up the corresponding dunder method on the object's class, enabling operator overloading in a clean, syntactic way.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
They enable operator overloading for user-defined classes.
Why this is correct
Special methods allow user-defined classes to redefine how operators such as +, -, ==, and < behave by implementing reserved dunder names like __add__, __eq__, or __lt__. When Python evaluates an expression like a + b, it dispatches to a.__add__(b) (or the reflected method on b if needed), enabling custom types to support the same syntactic sugar as built-in types. For example, a Vector class can define __add__ to perform element-wise addition, making v1 + v2 valid.
- ✓
They can be defined in a class to customize behavior.
Why this is correct
Defining special methods inside a class lets you customize how objects respond to construction, string formatting, attribute access, and other built-in operations. For instance, overriding __init__ controls initialization, while a custom __repr__ changes how an instance is displayed by the REPL and debuggers. Because these hooks are inherited and can be overridden in subclasses, a class can precisely tailor its behavior to fit expected protocols without affecting other types.
- ✗
Every class automatically has all special methods predefined.
Why it's wrong here
This statement is false: the base object class only provides a handful of special methods—like __str__, __repr__, and __eq__—while leaving many protocol methods undefined. Calling len(x), iter(x), or x + y on a class that never defined __len__, __iter__, or __add__ raises an exception rather than falling back to a default implementation. The interpreter only recognizes dunder methods that are actually declared somewhere in the type's MRO, so 'automatic' availability is limited to what object supplies.
- ✗
They must be defined inside the class definition and cannot be added later.
Why it's wrong here
This is not a requirement: since classes are mutable objects in Python, you can patch a special method onto a class after its definition, such as setting SomeClass.__lt__ = custom_func at runtime. Such late-bound methods are then honored by the interpreter because implicit special-method lookup happens on the type, not on the instance. That said, this practice is uncommon and discouraged for maintainability, but it is syntactically and semantically allowed.
- ✓
They are automatically invoked by Python in certain contexts.
Why this is correct
Python's runtime explicitly triggers special methods at predetermined points: len(x) calls type(x).__len__(x), for loops call __iter__/__next__, and attribute access uses __getattribute__/__getattr__. User code rarely calls these methods directly with their dunder names; instead, writing built-in functions like abs(x) or the with statement automatically invokes x.__abs__ or x.__enter__/__exit__. This implicit invocation is what makes user-defined objects integrate seamlessly with language syntax.
Go deeper
Related to this question
About these practice questions
This PCAP question is part of Courseiva's 421-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 →
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.