0% found this document useful (0 votes)
22 views2 pages

Python OOPs Interview Questions

The document outlines key Object-Oriented Programming (OOP) concepts in Python, including definitions of classes, objects, and core principles such as encapsulation, inheritance, and polymorphism. It also discusses the benefits of OOP, method types, magic methods, and memory management. Additionally, it covers advanced topics like method resolution order, composition, and data classes.

Uploaded by

raviapte84
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views2 pages

Python OOPs Interview Questions

The document outlines key Object-Oriented Programming (OOP) concepts in Python, including definitions of classes, objects, and core principles such as encapsulation, inheritance, and polymorphism. It also discusses the benefits of OOP, method types, magic methods, and memory management. Additionally, it covers advanced topics like method resolution order, composition, and data classes.

Uploaded by

raviapte84
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Python OOPs Interview Questions (Basic to Advanced)

Q: What is Object-Oriented Programming (OOP)?

A: Object-Oriented Programming is a programming paradigm that uses 'objects' and 'classes'. Core principles:
Encapsulation, Abstraction, Inheritance, and Polymorphism.

Q: What are the benefits of using OOP in Python?

A: Promotes code reusability, modularity, maintainability, and security.

Q: Define class and object with an example.

A: A class is a blueprint. An object is an instance of that class.

Q: What is the role of the self keyword in Python?

A: 'self' refers to the current object. It's used to access instance variables and methods.

Q: What is inheritance in Python?

A: Inheritance allows one class to acquire attributes and methods from another.

Q: What is encapsulation? How is it achieved in Python?

A: Encapsulation restricts direct access to data. Achieved using public, protected (_var), and private (__var) access.

Q: What is method overriding?

A: When a child class redefines a method from the parent class.

Q: What is polymorphism in Python?

A: It allows methods to perform differently based on the object.

Q: What is abstraction?

A: Abstraction hides complex details and shows only the essential features using abstract base classes.

Q: Difference between static, class, and instance methods?

A: Static: no self or cls. Class: uses cls. Instance: uses self.

Q: What are magic methods in Python?


Python OOPs Interview Questions (Basic to Advanced)
A: Special methods with double underscores, like __init__, __str__, used to mimic built-in behaviors.

Q: What is MRO in Python?

A: Method Resolution Order determines the order in which base classes are searched.

Q: What is composition in OOP?

A: Composition means one class contains another. Promotes modular design.

Q: What are data classes in Python?

A: Introduced in Python 3.7 to reduce boilerplate in classes that only store data.

Q: What is the difference between shallow copy and deep copy?

A: Shallow: copies only references. Deep: copies everything recursively.

Q: How is memory managed in Python OOP?

A: Through reference counting and garbage collection.

Q: Can Python support multiple constructors?

A: Not directly. Use class methods to simulate multiple constructors.

You might also like