What is an object in Object Oriented Programming (OOP)
Definition of an object in OOP -
An object is an entity or instance of a class. The objects are mostly the physical entity but it can be a logical entity as well. Each object has state and behaviours.
The states of the objects means the values or data in the form of variables and behaviours means the actions or functions those perform some operations on the data. For instance, Dogs have state (name, color, breed, hungry) and behaviour (barking, fetching, wagging tail).
An Object Example:
Every object is built from a class. The objects occupy the memory space.
An object always model or depicts the real world entities like a mango, the Hero Passion, Toyota Fortuner, etc.
Advantages / benefits of the objects:
- Objects can hide the actual data from the outside world by making the data private and allowing the data access through the functions or methods only.
- The source codes of each object are independent of each other, so we can achieve the modularity in the program using objects.
- If an object is raising some errors so we can easily replace with another so the debugging becomes easy.
You May Like to Know