Courseiva

PCAP · topic practice

Object-Oriented Programming practice questions

This domain covers Python's object-oriented programming features: class definition, inheritance, polymorphism, encapsulation, special methods, and the @property decorator. Questions present code snippets or design scenarios and ask you to predict behavior, choose the correct syntax, or select the best approach. You must understand method resolution, attribute access, and how Python implements OOP without explicit interfaces.

Courseiva uses original exam-style practice questions designed for learning and revision. The goal is to understand the concepts, recognise exam patterns, and improve through explanations — not memorise copied exam dumps.

Editorial oversight:Johnson Ajibi· MSc IT Security, IEEE Senior Member
20 questionsDomain: Object-Oriented Programming

What the exam tests

What to know about Object-Oriented Programming

You must be able to read and write Python classes that use inheritance, encapsulation, and special methods correctly. The single most important thing is to understand how attribute lookup works, including instance vs class attributes and the role of @property for controlled access.

Creating classes with __init__, instance attributes, and class attributes

Using inheritance, super(), and method overriding for polymorphism

Implementing encapsulation with name mangling and @property getters/setters

Defining special methods like __str__, __repr__, and __eq__

Why learners struggle

Why Object-Oriented Programming questions are commonly missed

RAM questions are commonly missed because learners confuse physical form factors (DIMM vs SO-DIMM) and fail to distinguish between memory speed (MHz) and latency (CL).

  • ·DIMM vs SO-DIMM — desktop vs laptop form factor confusion
  • ·DDR3 vs DDR4 vs DDR5 — notch position and voltage differences
  • ·MHz vs CL — speed vs latency trade-offs in performance
  • ·Single-channel vs dual-channel — bandwidth impact misconception
  • ·ECC vs non-ECC — error correction support in servers vs desktops
  • ·32-bit vs 64-bit — maximum addressable RAM limit

Watch out for

Common Object-Oriented Programming exam traps

  • ▸Confusing class attributes with instance attributes, leading to shared state across instances.
  • ▸Forgetting that name mangling uses double underscore prefix and does not truly prevent access.
  • ▸Misusing @property setter syntax, such as missing @score.setter or incorrect method names.

Practice set

Object-Oriented Programming questions

20 questions · select your answer, then reveal the explanation

A class 'Employee' has a method 'work()'. A subclass 'Manager' overrides 'work()' but also wants to call the parent's 'work()'. Which syntax correctly achieves this?

A Python program uses multiple inheritance. Class A defines method 'foo', class B also defines 'foo', and class C(A, B) inherits from both. The developer expects that calling 'foo' on an instance of C should invoke the method from class A. However, it invokes the method from class B. What is the most likely cause?

Which TWO of the following are valid ways to define a class attribute that is shared by all instances?

During code review, a team member wrote: 'class Dog(Animal): pass'. The Animal class has an __init__ method that requires a 'name' parameter. When instantiating Dog, what should be done to properly initialize the inherited attributes?

A developer needs to create a class that cannot be instantiated directly but serves as a base for other classes. Which approach should be used?

Which TWO of the following are valid ways to define a class attribute (as opposed to an instance attribute) in Python?

Refer to the exhibit. What is the output?

Exhibit

class Counter:
    count = 0
    def __init__(self):
        Counter.count += 1
    @classmethod
    def get_count(cls):
        return cls.count

c1 = Counter()
c2 = Counter()
print(Counter.get_count())
print(c1.get_count())
print(c2.get_count())

Drag and drop the steps to create a Python package with subpackages into the correct order.

Drag or tap steps into the slots.

Steps
Order
1Step 1
2Step 2
3Step 3
4Step 4
5Step 5

Which of these is NOT a characteristic of Python's descriptor protocol?

Which THREE statements about inheritance in Python are correct?

Refer to the exhibit. What is the output?

Exhibit

class MyClass:
    def __init__(self, value):
        self.value = value

obj = MyClass(10)
print(obj.value)

A developer implements a descriptor class with `__get__` and `__set__` methods. When an instance attribute is accessed, what determines whether the descriptor is used?

Refer to the exhibit. What is the output when the code is executed?

Exhibit

class MyClass:
    def __getattr__(self, name):
        return f"Default {name}"
    def __setattr__(self, name, value):
        self.__dict__[name] = value.upper()

obj = MyClass()
obj.x = "hello"
print(obj.x)

Refer to the exhibit. What is the output?

Exhibit

class Circle:
    def __init__(self, radius):
        self._radius = radius

    @property
    def radius(self):
        return self._radius

    @radius.setter
    def radius(self, value):
        if value > 0:
            self._radius = value

c = Circle(5)
c.radius = -3
print(c.radius)

You are designing a class that should behave like a sequence and support slicing. Which special methods must be implemented?

Which TWO statements about inheritance in Python are true?

Which THREE methods must be implemented to create an immutable object that supports iteration and membership testing?

Refer to the exhibit. Which of the following is true about MyClass?

Exhibit

>>> help(MyClass)
Help on class MyClass in module __main__:
class MyClass(builtins.object)
 |  Methods defined here:
 |  
 |  __init__(self, value)
 |      Initialize self.  See help(type(self)) for accurate signature.
 |  
 |  display(self)
 |      Print the value.
 |  
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |  
 |  __dict__
 |      dictionary for instance variables (if defined)
 |  
 |  __weakref__
 |      list of weak references to the object (if defined)

Which THREE of the following are true about method overriding in Python?

Refer to the exhibit. Which statement correctly creates an instance of `Dog` and calls the `bark` method?

Exhibit

class Dog:
    def __init__(self, name):
        self.name = name
    def bark(self):
        return "Woof!"

Free account

Track your progress over time

Create a free account to save your results and see which topics improve across sessions.

Focused Object-Oriented Programming sessions

Start a Object-Oriented Programming only practice session

Every question in these sessions is drawn from the Object-Oriented Programming domain — nothing else.

Related practice questions

Related PCAP topic practice pages

Move into related areas when this topic feels solid.

Frequently asked questions

What does the PCAP exam test about Object-Oriented Programming?
You must be able to read and write Python classes that use inheritance, encapsulation, and special methods correctly. The single most important thing is to understand how attribute lookup works, including instance vs class attributes and the role of @property for controlled access.
How should I use these practice questions?
Select your answer before revealing the explanation. Then read why each option is right or wrong — this active recall approach builds retention far faster than re-reading notes.
Can I practise just Object-Oriented Programming questions in a focused session?
Yes — the session launcher on this page draws every question from the Object-Oriented Programming domain. Use a 10-question session first to gauge your baseline, then move to 20 or 30 once the weak spots are clear.
Where can I practise other PCAP topics?
Use the topic links above to move to related areas, or go back to the PCAP question bank to see all topics.
Are these real exam questions or dumps?
These are original practice questions written to test the same concepts the PCAP exam covers. They are not copied from any real exam or dump site.