🧠 OOP (Object-Oriented Programming) –
Object & Instantiation
📌 What is OOP?
OOP stands for Object-Oriented Programming.
In OOP, everything revolves around objects.
To perform any operation, we use objects — without objects, no real interaction with class data is possible.
🧱 What is an Object?
An object is an instance of a class.
It represents a real-world entity.
🔹 Examples
Bus 🚍
Pen 🖊️
Ball ⚽
🔍 Entity Concept
Any entity that has:
Identity
State
Behavior
👉 is called an object/entity.
⚙️ Characteristics of an Object
1️⃣ State
Represents data (variables)
Example: color, size, speed
2️⃣ Behavior
Represents methods (functions)
Example: run(), write(), move()
⏱️ Runtime Object
A runtime object is created during program execution.
It comes into existence when the program runs and memory is allocated.
🏗️ Instantiation
Instantiation means creating an object and allocating memory to it.
✅ Syntax
Class_Name <object_name> = new Class_Name();
📌 Explanation
Class_Name→ Class<object_name>→ Object (instance)new→ Allocates memory and creates object
⚠️ Important Points
When a class is defined → ❌ No memory is allocated
When an object is created (instantiated) → ✅ Memory is allocated
newkeyword → Memory allocation operator
🧠 Key Takeaways
Object = Instance of a class
Objects represent real-world entities
Instantiation = Object creation + memory allocation
newkeyword is mandatory to create objectsObjects enable access to data and behavior defined in class
This forms the core foundation of OOP, essential for mastering concepts like encapsulation, inheritance, and polymorphism.
Comments
Post a Comment