Sitemap

Java OOP: Classes, Objects

2 min readMay 23, 2026

--

Object-Oriented Programming (OOP) can feel abstract, but at its core, it mirrors the real world. Let’s break down three foundational pillars of Java OOP using structured definitions and real-world examples.

1. Defining a Class: The Blueprint

Think of a Class as an architectural drawing or a prototype. You cannot live inside a blueprint of a house; instead, the blueprint dictates the structure, characteristics, and actions common to all houses built from it.

  • What it is: A user-defined template or prototype that represents a set of properties (variables) or methods common to all objects of that type.
  • In Java, it looks like this:
class Vehicle {
// Instance variables (Properties)
String brand;
int speed;
// Methods (Behaviors)
void accelerate() {
speed += 10;
}
}

2. Instantiating an Object: The Reality

An Object is the real-world entity built directly from your blueprint. If Vehicle is the class, then your physical car parked outside is the object!

Get Priyanka Hajare’s stories in your inbox

Join Medium for free to get updates from this writer.

Creating an object from a class involves three critical steps:

  • Declaration: Associating a variable name with an object type.
  • Instantiation: Using the new keyword to allocate memory and create the physical object space.
  • Initialization: Following the new keyword with a call to a constructor to initialize its initial state.
// Combining Declaration, Instantiation, and Initialization
Vehicle myCar = new Vehicle();
Press enter or click to view image in full size
class and object java

--

--

Priyanka Hajare
Priyanka Hajare

Written by Priyanka Hajare

An educator and lifelong learner Beyond tech, I am passionate about writing and understanding human psychology. Always ready to collaborate and learn.