Python OOP Interview Notes
1. OOP = Object-Oriented Programming. Organizes code using Classes and Objects.
2. Class: Blueprint. Object: Instance of a class.
3. Constructor (__init__): Initializes object data.
4. self: Refers to the current object.
5. Four Pillars:
- Encapsulation: Hide data using private members (__var).
- Abstraction: Show only essential features, hide implementation.
- Inheritance: Reuse code from parent class.
- Polymorphism: Same method name, different behavior (method overriding).
6. Types of Inheritance: Single, Multiple, Multilevel, Hierarchical, Hybrid.
7. Method Overriding: Child replaces parent method.
8. Method Overloading: Not directly supported; use default arguments/*args.
9. super(): Calls parent constructor/method.
10. Access Modifiers: Public, Protected(_), Private(__).
11. Class Variable: Shared by all objects. Instance Variable: Unique per object.
12. Static Method: @staticmethod, no self.
13. Class Method: @classmethod, uses cls.
14. Benefits: Code reuse, modularity, maintainability, scalability, security.
15. Common Interview Questions:
- Difference between Class and Object?
- Why use OOP?
- Explain Encapsulation with example.
- Difference between Inheritance and Composition?
- Difference between Class variable and Instance variable?
- What is super()?
- Difference between @staticmethod and @classmethod?
30-Second Interview Answer:
Python OOP is a programming paradigm that organizes code into classes and objects. It
improves code reusability, maintainability, and security through Encapsulation,
Abstraction, Inheritance, and Polymorphism. These concepts help build scalable and
real-world applications.