</>
ShikshaCSLearn. Code. Grow.
🔍
☕ Support Us
ShikshaCSâ€ēNotesâ€ēObject Oriented Programming
Object Oriented Programming
🕒 6 min read

Classes and Objects

The building blocks of OOP — a blueprint and its real instances.

What is a Class?

A class is a blueprint that defines properties (attributes) and behaviors (methods) that its objects will have. It doesn't hold real data itself — it's the template.

What is an Object?

An object is a specific instance of a class, created using that blueprint, with its own actual values for the class's attributes.

class Car {
  constructor(brand) { this.brand = brand; }
  drive() { console.log(this.brand + " is driving"); }
}
const myCar = new Car("Tata"); // object
myCar.drive();

Why OOP?

OOP models real-world entities naturally, making large codebases easier to organise, reuse, and maintain compared to writing everything as separate functions.

🌍 Real-World Use

In a food delivery app, 'Order', 'Restaurant', and 'DeliveryPartner' would each be classes. Every actual order placed by a customer is an object created from the 'Order' class blueprint.

💡 Pro Tip

A common mistake is confusing a class with an object in interview answers — always say 'a class is the blueprint, an object is the actual thing built from it' to show clear understanding.

đŸ§Ē Quick Self-Test

Check what you just learned — no pressure, just practice.

1. What is a class?

2. How many objects can you create from one class?

← Back to all Notes