โ† All POC Flashcard Decks

Object-Oriented Programming in Python Flashcards

7 cards from real POC practice questions. Tap to flip, then mark Knew It or Still Learning โ€” missed cards come back until you master them.

Read the first 7 Object-Oriented Programming in Python flashcards as text
  1. What is polymorphism in the context of Python OOP?

    Answer: The ability of different objects to respond to the same method call in different ways

    Polymorphism allows objects of different types to be treated through a common interface, each responding according to its own implementation.

  2. Which of the following is an example of duck typing in Python?

    Answer: Calling a method on an object regardless of its class, trusting it has that method

    Duck typing means Python calls a method on any object that has it, without checking the object's actual type first.

  3. What is the output of calling `type(42)`?

    Answer:

    `type(42)` returns `` because 42 is an integer object in Python.

  4. What does the `@staticmethod` decorator do?

    Answer: Defines a method that does not receive the instance or class as an implicit first argument

    A static method doesn't receive `self` or `cls`; it behaves like a regular function scoped inside the class.

  5. Which method is called when an object is about to be garbage collected?

    Answer: __del__

    `__del__` is the destructor method, called when the object's reference count drops to zero.

  6. What is an abstract class in Python?

    Answer: A class that cannot be instantiated and is meant to be subclassed, often using the `abc` module

    Abstract classes (via `abc.ABC` and `@abstractmethod`) enforce that subclasses implement specific methods before instantiation.

  7. Given `class B(A):`, what happens if `B` does not override method `foo` defined in `A`?

    Answer: Calling `b.foo()` executes `A`'s version of `foo`

    Python's MRO (Method Resolution Order) looks up the inheritance chain, so `B` inherits and can use `A`'s `foo` unchanged.