Skip to main content
PreparationZone Logo
PreparationZone
Back to Fundamentals

Fundamentals · Easy · Free

What is the difference between a class and an object?

FresherFundamentalsOOP & Language Fundamentals
Model answer

Class vs object

A class is a blueprint (fields + methods). An object is a runtime instance of that class with its own state on the heap.

java
class Student { String name; int rollNo; }
Student s1 = new Student(); // object
s1.name = "Riya";
  • Class exists once per classloader; many objects can be created with new.
  • Static members belong to the class; instance members belong to each object.
Analogy: class = cookie cutter, object = each cookie.