📘 PAPER 2: OBJECT ORIENTED PROGRAMMING WITH PYTHON UNIT 3 – Classes, Objects & OOP Concepts (university of allahabad)
🔴 UNIT 3 – Classes, Objects & OOP Concepts
1️⃣ Class and Object
✅ Class
A class is a blueprint or template used to create objects.
📌 It defines:
-
Data members (variables)
-
Member functions (methods)
Example:
✅ Object
An object is an instance of a class.
🔹 Key Difference
| Class | Object |
|---|---|
| Blueprint | Real-world entity |
| Logical | Physical |
| No memory | Uses memory |
2️⃣ Abstract Data Type (ADT)
✅ Definition
An ADT defines:
-
What operations are to be performed
-
Not how they are implemented
It focuses on behavior, not implementation.
Example:
3️⃣ Classes and Objects in Python
Example Program:
4️⃣ Constructor (__init__)
Definition:
A constructor is a special method used to initialize objects.
Example:
5️⃣ Features of OOP in Python
🔹 1. Encapsulation
Binding data and methods together.
✔ Data hiding
✔ Security
🔹 2. Abstraction
Showing essential features and hiding internal details.
Achieved using:
🔹 3. Inheritance
Child class inherits properties of parent class.
Types of Inheritance:
-
Single
-
Multiple
-
Multilevel
-
Hierarchical
-
Hybrid
🔹 4. Polymorphism
Same function behaves differently.
Example:
6️⃣ Abstract Class
Definition:
An abstract class contains abstract methods (methods without body).
Using abc module:
7️⃣ Scope in Python
Types of Scope:
-
Local
-
Global
-
Non-local
-
Built-in
Example:
8️⃣ Multithreading in Python
✅ Definition
Multithreading means executing multiple threads simultaneously.
Is Multithreading Supported in Python?
✔ Yes
❌ But limited due to GIL (Global Interpreter Lock)
Example:
Advantages:
-
Faster execution
-
Better CPU utilization
-
Useful in I/O operations
Disadvantages:
-
Complex debugging
-
GIL limits performance
Comments
Post a Comment