Learn with Yasir

Share Your Feedback

polymorphism in Python - True or False Questions with Answers


Test your understanding of Object-Oriented Programming (OOP) in Python with these carefully crafted True or False questions on polymorphism. Great for beginners and intermediate learners to reinforce OOP concepts.

🔍 True or False

🟢 Beginner

  1. In Python, polymorphism is only possible through inheritance.
  2. Answer

    ❌ False – Polymorphism in Python can be achieved through both inheritance (method overriding) and duck typing (shared interfaces), not just inheritance.


  3. Polymorphism allows objects of different classes to be treated as objects of a common superclass.
  4. Answer

    ✅ True – Polymorphism enables treating different class instances through a common interface, allowing for flexible and reusable code.


  5. The built-in len() function in Python is an example of polymorphism.
  6. Answer

    ✅ True – The len() function works with different types (strings, lists, tuples, etc.) because they all implement the __len__() method, demonstrating polymorphism.


  7. The + operator in Python behaves differently with strings and numbers, demonstrating polymorphism.
  8. Answer

    ✅ True – The + operator performs concatenation with strings and addition with numbers, showing operator overloading which is a form of polymorphism.


🟡 Intermediate

  1. Method overloading is a common way to achieve polymorphism in Python.
  2. Answer

    ❌ False – Python doesn't support method overloading (multiple methods with same name but different parameters) in the traditional sense. Polymorphism is typically achieved through method overriding or duck typing.


  3. Duck typing is a form of polymorphism where the suitability of an object is determined by the presence of certain methods and properties.
  4. Answer

    ✅ True – Duck typing ("if it walks like a duck and quacks like a duck...") is a Pythonic approach to polymorphism that focuses on an object's behavior rather than its type.


🔴 Advanced

  1. Python's abstract base classes (ABCs) prevent polymorphism from occurring.
  2. Answer

    ❌ False – ABCs actually facilitate polymorphism by enforcing a common interface that subclasses must implement, while still allowing different implementations.


📚 Related Resources