Python Polymorphism Questions and Answers
Python Programming - Polymorphism Questions with Answers help learners understand how objects share methods in object-oriented programming. These Python Polymorphism Questions are vital for TCS, Infosys, Wipro, and SSC exams, making it easier to master function overloading and overriding concepts in Python
Python Polymorphism
Showing 10 of
25 questions
1. What is polymorphism in Python?
- Ability to take multiple forms
- Ability to hide implementation details
- Ability to inherit from multiple classes
- Ability to restrict access to methods
2. Which of the following is an example of method overriding in Python?
- Defining __init__ method in a class
- Using the same method name in parent and child class
- Using different method names for similar operations
- Creating multiple methods with same name in same class
3. What is duck typing in Python?
- Checking object type before method calls
- If it looks like a duck and quacks like a duck, it is a duck
- Strict type checking at compile time
- Automatic type conversion between objects
4. Which built-in function demonstrates polymorphism in Python?
- type()
- len()
- id()
- isinstance()
5. What is method overloading in Python?
- Multiple methods with same name but different parameters
- Multiple methods with different names but same parameters
- Changing method behavior at runtime
- Hiding method implementation from user
6. Which operator overloading method is used for addition?
- __plus__
- __sum__
- __add__
- __append__
7. What is the main advantage of polymorphism?
- Faster execution
- Code flexibility and reusability
- Smaller code size
- Automatic memory management
8. Which concept allows the + operator to work with both numbers and strings?
- Method overriding
- Operator overloading
- Method overloading
- Inheritance
9. What is runtime polymorphism in Python?
- Method overloading
- Method overriding
- Operator overloading
- Function overloading
10. Which method is used for string representation of an object?
- __repr__
- __str__
- __string__
- __display__