Python OOP and Exception Handling Interview Questions
Python OOP and Exception Handling Interview Questions
Answer: - Encapsulation
- Inheritance
- Polymorphism
- Abstraction
Answer: Inheritance allows a class to use methods and properties from another.
Types: Single, Multiple, Multilevel, Hierarchical, Hybrid
Answer: Yes, Python supports multiple inheritance. A class can inherit from more than one
base class.
13. Q: What is encapsulation in Python?
Answer: Binding data and methods together and restricting direct access using _ (protected)
and __ (private).
Answer: The ability of different classes to use the same interface. Example: different classes
have the same method name.
Answer: Special methods with double underscores, e.g., __init__, __str__, __len__, __add__
Answer: MRO is the order in which base classes are searched when executing a method.
Python uses C3 linearization.
🔹 Exception Handling
20. Q: How does Python handle exceptions?