Objects are the small, self-contained and modular units with a well-defined boundary. An Object is a Real Word Thing Which performs a Specific Task. An object consists of a state (Properties) and behavior (Method). The state of an object is one of the possible conditions that an object can exist in and is represented by its characteristics or attributes or data or Properties of Object. The behavior of an object determines how an object acts or behaves and is represented by the operations that it can perform. In OOP, the attributes of an object are represented by the variables and the operations are represented by the functions.
For example, A Car is an Object which has a Certain Number of Properties Like Color, Model No, Average etc and a Function Known as Run When A User gives Some Race then the Car Will be Moved. An object biscuit may consist of data product code P00l, product name Britannia Biscuits, price 20 and quantity in hand 50. These data specify the attributes or features of the object. Similarly, consider another object Maggi with data product code P002, product name Maggi Noodles, price 10, and quantity in hand 20. In addition, the data in the object can be used by the functions such as check_qty() and display_product(). These functions specify the actions that can be performed on data.
Objects are what actually runs in the computer and thus, are the basic run-time entities in object-oriented systems. They are the building blocks of object-oriented programming. Although, two or more objects can have same attributes, still they are separate and independent objects with their own identity. In other words, all the objects in a system take a separate space in the memory independent of each other. The main objective of breaking down complex software projects into objects is that changes made to one part of a software should not adversely affect the other parts.
Class : A class is defined as a user-defined data type, which contains the entire set of (properties and Methods) similar data and the functions that the objects possess. In other words, a class in OOP represents a group of similar objects. Like Animals is name of class which contains all the Properties and Methods of an Object of another Animals So if we wants to access any data from the Class then first we have to create the Object of a class Then we can use any data and method from class However, each of them can be categorized under different groups depending on the common properties they possess and the functions they perform. For example, cars, scooters, motorbikes, buses all can be grouped under the category vehicles. Similarly, dogs, cats, horses, etc., can be categorized under the group animals. Thus, vehicles -and animals can be considered as the classes.
A class serves as a blueprint or template for its objects. That is, once a class has been defied, any number of objects belonging to that class can be created. The objects of a class are also known as the instances or the variables of that class and the process of creating objects from a class is known as instantiation. Note that a class does not represent an object, rather it represents the data and functions that an object should have.
For example, a class Product consists of data such as p_code, p_name, p_price and qty_in_hand which specify the attributes or features of the objects of the Product class. In addition, it consists of functions such as display_product() and check_qty() that specify the actions that can be performed on data.
Note that the data belonging to a particular class is known as its data members and the functions of the class are known as the member functions and both collectively are known as the members of the class.