Prévia do material em texto
What are Objects in Programming?
Last Updated : 22 Jan, 2026
In Object-Oriented Programming, an object is a real-time entity that represents a specific instance of a
class and occupies memory at runtime. A class acts as a blueprint, while memory is allocated only
when an object is created.
Objects allow access to class data members and invocation of class methods.
They are used to perform actual operations defined by the class.
Objects help represent real-world entities in a program.
Real-world Example of Object
The objects for the class Account are SBI Account, ICICI Account, etc. Each object represents a distinct
account with its own data, even though all follow the same class structure. Similar is shown with the
help of the diagram below:
Relation Between class and object
Characteristics of an object
Every object in OOP has the following three essential characteristics:
1. Identity
Each object has a unique identity, which distinguishes it from other objects, even if they belong to the
same class. This identity is usually represented by the object reference. No two objects share the
same identity in memory.
2. State
The state of an object represents the current values of its attributes (variables). These values are
typically initialized using constructors and can change during program execution.
Example:
Account acc = new Account(1000);
Sign In
Courses
Tutorials
Interview Prep
06/08/2026, 10:44 What are Objects in Programming? - GeeksforGeeks
https://www.geeksforgeeks.org/java/what-are-objects-in-programming/ 1/3
https://www.geeksforgeeks.org/
Comment GeeksforGeeks
Explore
Basics
OOP & Interface
Here, 1000 defines the initial state of the object.
3. Behavior
The behavior of an object is defined by the methods it can perform. These methods operate on the
object’s state and represent its functionality.
Example behaviors: deposit(), withdraw(), checkBalance().
Output
Balance: 1500
Balance: 2000
Explanation:
Identity: acc1 and acc2 are two different objects in memory.
State: balance holds the current value for each object.
Behavior: deposit() and checkBalance() define what the object can do.
6
class Account {
int balance; // State (data members)
// Constructor
Account(int balance) {
this.balance = balance;
}
// Behavior
void deposit(int amount) {
balance += amount;
}
void checkBalance() {
System.out.println("Balance: " + balance);
}
}
public class Main {
public static void main(String[] args) {
// Creating objects
Account acc1 = new Account(1000);
Account acc2 = new Account(2000);
acc1.deposit(500);
acc1.checkBalance();
acc2.checkBalance();
}
}
Sign Intorial Advanced Java Interview Questions Exercises Examples Quizzes Projects Cheatsheet DSA in Java Java Co
06/08/2026, 10:44 What are Objects in Programming? - GeeksforGeeks
https://www.geeksforgeeks.org/java/what-are-objects-in-programming/ 2/3
https://www.geeksforgeeks.org/user/code_r/
https://www.geeksforgeeks.org/user/code_r/
https://www.geeksforgeeks.org/user/code_r/
https://www.geeksforgeeks.org/java/java/
https://www.geeksforgeeks.org/advance-java/advanced-java/
https://www.geeksforgeeks.org/java/java-interview-questions/
https://www.geeksforgeeks.org/java/java-exercises/
https://www.geeksforgeeks.org/java/java-programming-examples/
https://www.geeksforgeeks.org/java/java-quiz/
https://www.geeksforgeeks.org/blogs/java-projects/
https://www.geeksforgeeks.org/java/java-cheat-sheet/
https://www.geeksforgeeks.org/dsa/dsa-in-java/
https://www.geeksforgeeks.org/java/java-collection-tutorial/
Collections
Advance Java Concepts
Practice Java
Courses
Corporate & Communications Address:
A-143, 6th Floor, Sovereign Corporate
Tower, Sector- 136, Noida, Uttar
Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante
Apartment, Sector 137, Noida, Gautam
Buddh Nagar, Uttar Pradesh, 201305
Company
About Us
Legal
Privacy
Policy
Contact Us
Advertise
with us
GFG
Corporate
Solution
Campus
Training
Program
Explore
POTD
Job-A-
Thon
Blogs
Nation
Skill Up
Tutorials
Programming
Languages
DSA
Web
Technology
AI, ML &
Data Science
DevOps
CS Core
Subjects
Interview
Preparation
Software and
Tools
Courses
ML and Data
Science
DSA and
Placements
Web
Development
Programming
Languages
DevOps &
Cloud
GATE
Trending
Technologies
Videos
DSA
Python
Java
C++
Web
Development
Data Science
CS Subjects
Preparation
Corner
Interview
Corner
Aptitude
Puzzles
GfG 160
System Design
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
06/08/2026, 10:44 What are Objects in Programming? - GeeksforGeeks
https://www.geeksforgeeks.org/java/what-are-objects-in-programming/ 3/3
https://www.geeksforgeeks.org/
https://in.linkedin.com/company/geeksforgeeks
https://www.instagram.com/geeks_for_geeks/
https://twitter.com/geeksforgeeks
https://www.facebook.com/geeksforgeeks.org/
https://www.youtube.com/geeksforgeeksvideos
https://www.geeksforgeeks.org/about/
https://www.geeksforgeeks.org/legal/
https://www.geeksforgeeks.org/legal/privacy-policy/
https://www.geeksforgeeks.org/about/contact-us/
https://www.geeksforgeeks.org/advertise-with-us/
https://www.geeksforgeeks.org/gfg-corporate-solution/
https://www.geeksforgeeks.org/campus-training-program/
https://www.geeksforgeeks.org/problem-of-the-day
https://practice.geeksforgeeks.org/events/rec/job-a-thon/
https://www.geeksforgeeks.org/category/blogs/?type=recent
https://www.geeksforgeeks.org/nation-skill-up/
https://www.geeksforgeeks.org/computer-science-fundamentals/programming-language-tutorials/
https://www.geeksforgeeks.org/dsa/dsa-tutorial-learn-data-structures-and-algorithms/
https://www.geeksforgeeks.org/web-tech/web-technology/
https://www.geeksforgeeks.org/machine-learning/ai-ml-and-data-science-tutorial-learn-ai-ml-and-data-science/
https://www.geeksforgeeks.org/devops/devops-tutorial/
https://www.geeksforgeeks.org/gate/gate-exam-tutorial/
https://www.geeksforgeeks.org/aptitude/interview-corner/
https://www.geeksforgeeks.org/websites-apps/software-and-tools-a-to-z-list/
https://www.geeksforgeeks.org/courses/category/machine-learning-data-science
https://www.geeksforgeeks.org/courses/category/dsa-placements
https://www.geeksforgeeks.org/courses/category/development-testing
https://www.geeksforgeeks.org/courses/category/programming-languages
https://www.geeksforgeeks.org/courses/category/cloud-devops
https://www.geeksforgeeks.org/courses/category/gate
https://www.geeksforgeeks.org/courses/category/trending-technologies/
https://www.geeksforgeeks.org/videos/category/sde-sheet/
https://www.geeksforgeeks.org/videos/category/python/
https://www.geeksforgeeks.org/videos/category/java-w6y5f4/
https://www.geeksforgeeks.org/videos/category/c/
https://www.geeksforgeeks.org/videos/category/web-development/
https://www.geeksforgeeks.org/videos/category/data-science/
https://www.geeksforgeeks.org/videos/category/cs-subjects/
https://www.geeksforgeeks.org/interview-prep/interview-corner/
https://www.geeksforgeeks.org/aptitude/aptitude-questions-and-answers/
https://www.geeksforgeeks.org/aptitude/puzzles/
https://www.geeksforgeeks.org/courses/gfg-160-series
https://www.geeksforgeeks.org/system-design/system-design-tutorial/
https://www.geeksforgeeks.org/
https://www.geeksforgeeks.org/copyright-information/
https://geeksforgeeksapp.page.link/gfg-app
https://geeksforgeeksapp.page.link/gfg-app