PCAP Object-Oriented Programming Practice Question
A team wants a `Logger` class that can be used both as `Logger.log('msg')` on the class itself and as `logger.log('msg')` on an instance, with identical behaviour and no access to instance state. Which decorator should be applied to `log`?
⚠ Common exam trap
The trap here is choosing a class method because it is callable from both the class and instances, overlooking that it injects an unused class argument the scenario does not need.
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
✓
`@staticmethod`
A static method is bound to neither the instance nor the class, so it can be invoked through either the class name or an instance with the same argument list and the same result. Because the logging behaviour does not depend on instance or class state, the missing implicit parameter is not a limitation. A class method would work but needlessly injects the class as an argument, and the other decorators change attribute semantics rather than call binding.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
`@staticmethod`
Why this is correct
A static method receives no implicit first argument, so `Logger.log('msg')` and `logger.log('msg')` both call the same function with identical arguments and identical results. Since the method does not need instance state, the absence of `self` is not a problem, and there is no unused `cls` parameter to confuse callers. This exactly matches the requirement of identical behaviour from both the class and an instance.
- ✗
`@classmethod`
Why it's wrong here
A class method receives the class as its first argument, so calling `logger.log('msg')` passes the class rather than the instance. It does work on both the class and instances, but the method signature includes `cls`, which is unnecessary when no class state is used. It is a plausible choice, yet the requirement explicitly says the method needs no access to instance state and behaves identically in both call styles, which the simpler static method satisfies without an unused parameter.
- ✗
`@abstractmethod`
Why it's wrong here
An abstract method is meant to be overridden by subclasses and cannot be instantiated directly in a class that still declares it abstract. It does not change how the method is bound, so it does not provide the dual class-and-instance call behaviour by itself, and calling it on the class would simply run the placeholder body. This decorator addresses interface enforcement, not call-style flexibility.
- ✗
`@property`
Why it's wrong here
A property turns an attribute access into a method call, so `logger.log` would evaluate to the function's return value rather than a callable. Calling `Logger.log('msg')` would invoke the getter with the class as the instance argument, producing a value, not a log entry. A property is designed for computed attributes, not for methods that must remain callable on both the class and instances.
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 and reviewed by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
Last reviewed September 2026 · checked against the official Python Institute exam blueprint
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.