What is an Object?

In Object Oriented terms, an Object is a software unit of variables (properties) and methods (functions). These objects are often used to model the real-world objects that you find in everyday life. An Object's method provide the only way to access the data. So that the data is hidden and secure from the accidental alteration. An Object's data and methods encapsulated into a single entity. These (Data Encapsulation and Data hiding) are the key term used for describing an Object Oriented Language.


What is an Object?

An Object within Object Oriented Programming is an instance of a Class. That means a class is a blueprint for an object. Each Object was built from the same set of blueprints (Class) and therefore contains the same components . All Objects share the same copy of the member functions (methods), but maintain a separate copy of the member data (Properties). For example: Ford and Toyota share certain similar features and hence can be grouped to form the Object of the Class Car.


What is a Class?

Objects (instances) are created from the Class using the keyword "new". You can create as many instances of a class as you would like. When a new Object is created, then memory will be allocated for the class in heap memory area, which is called as an instance and its starting address will be stored in the object in stack memory area.

Object Oriented Programming representation of a Car Class

class Car { } Cars ford = new Car(); Cars toyota = new Car();