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.
❌ False – Polymorphism in Python can be achieved through both inheritance (method overriding) and duck typing (shared interfaces), not just inheritance.
✅ True – Polymorphism enables treating different class instances through a common interface, allowing for flexible and reusable code.
✅ True – The len() function works with different types (strings, lists, tuples, etc.) because they all implement the __len__() method, demonstrating polymorphism.
✅ True – The + operator performs concatenation with strings and addition with numbers, showing operator overloading which is a form of polymorphism.
❌ 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.
✅ 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.
❌ False – ABCs actually facilitate polymorphism by enforcing a common interface that subclasses must implement, while still allowing different implementations.