DEV Community

Debesh P.
Debesh P.

Posted on

Classes & Objects | Object Oriented Programming | Understanding OOP in Java | OOP Learning

yo bro!

So you’ve just stepped into Java, and people keep throwing around fancy terms like class and object… and you’re like:

"Bhai, what even is this?"

Don't worry. I'm gonna break this down for you like a homie explaining life hacks. By the end of this article, you'll be able to explain it to your friends like a pro — or even impress that one friend who thinks they’re a coding genius.


First Things First: What’s OOP?

Java is an object-oriented programming (OOP) language.
That basically means — instead of writing dry, boring instructions, Java lets you code in a way that’s closer to real life.

Like, if you're thinking of a car, Java says,
“Cool. Let’s turn that car into a class... and create real cars from it!”

That’s what OOP is all about — creating things (objects) from blueprints (classes).


What's a Class? (aka The Blueprint)

Imagine this. You're planning to start a burger shop. Before you actually make burgers, you write down a standard plan — size, ingredients, sauces, etc.

That plan? That’s your class.

In Java:
class
Class = Design. Structure. Plan.
It tells Java what your object can have and can do.

But remember — until now, you’ve got zero real burgers. It’s just the idea.


What’s an Object? (aka The Real Thing)

Now comes the fun part.

You take that burger plan (class) and actually make a burger. BOOM — that’s an object.

object

  • myBurger is the object.
  • It has real values — "Large", "Spicy Mayo", 150.
  • It performs real actions — prepare and pack.

Object = Real stuff. Alive. Functional.

You can make 100 burgers from the same plan. Each one can be different — different size, different sauce. But all came from the same class.


Class vs Object — Bro-Level Analogy

Real Life Coder Life
Mobile Phone Model Class (blueprint)
Your Actual iPhone Object (real phone)
Instagram Profile Template Class
Your Insta Account Object
Recipe Book Class
Dish You Cooked Object

One is the plan. The other is the real thing based on that plan.


Why Java Uses Classes and Objects?

Bro, Java uses classes and objects for a lot of smart reasons:

1. Clean & Organized Code

You’re not writing a messy script. You’re building a clean, modular system.

2. Reusability

Write once, use again and again. One class → multiple objects.

3. Closer to Real World

You think of a dog? Java says: Cool, create a Dog class and make 10 dogs with different names and barks.

4. Data + Behavior Together

A class doesn’t just hold data. It defines what the object does too.


Behind-the-Scenes: How Objects Are Created?

objects

Here’s what’s secretly happening:

  1. Java finds your Car class.
  2. It makes some memory space in the heap (don’t worry about this now).
  3. It connects your object myCar to the class.
  4. It gives you access to all the stuff inside the class — variables and methods.

So now myCar can drive, brake, and tell you its brand and color.


Bro, What’s a Constructor?

When you do:

constructor

You’re secretly calling a special method called a constructor.

A constructor is like the setup process when you build your object.

Example:

constructor

Now, create it like this:

constructor

Cool, right? It sets values at the moment you create the object.


Pro-Tip: You Can Have Multiple Objects

object

Each one is separate, but all come from the same class.
It’s like cloning ideas and giving each clone its own vibe.


Recap

  • Class = Blueprint (The plan, the idea)
  • Object = Real Thing (Made from the class)
  • Java is obsessed with objects. You gotta get comfy with this.
  • Everything in Java OOP is about creating things that live and work together.

Final Words – Bro to Bro

Bhai, mastering classes and objects is like leveling up in Java.
Once you get this, you can build apps, games, websites — anything.

Java is not just code. It's storytelling. You build your characters (objects), give them power (methods), and let them live in your digital world.

So next time someone asks,

“What's a class and object in Java?”

You tell them with full swag:

“Class is the idea. Object is the reality. Java is the game. I’m the player.”

Top comments (1)

 
debeshpg90 profile image
Debesh P.

connect with me on LinkedIn: linkedin.com/in/debesh-paul-4254511bb

stay tuned for more! 🙌