► Programs are divided into objects. ► Data structures are designed in a way that they characterize objects. ► Functions and data are tied together in the data structure so data abstraction is maintained. ► Data is hidden and can’t be accessed by external functions. ► Objects can communicate with each other through functions. ► New data and functions can be easily added whenever necessary. ► Follows bottom-up approach. OOP OOP : Features
► Object and Class
► Encapsulation ► Data Abstraction ► Inheritance ► Polymorphism Object and Class
An object is a bundle of variables and related functions.
It is the entity in an object oriented system through which we perceive the real-world around us. It is also defined as an instance of class. Objects are defined with their properties and methods. If we take a car as an example of object; properties : color, company, model, fuel methods : braking, accelerate etc. Class is a blueprint that specifies what data and functions are to be associated with the object. It serves as a plan or a framework where the objects are created. Object and Class
The block diagram here is the representation of
Car Class named Car. It has got properties: Name, Model, Color and Seats and the methods : Start(), Name Stop() and Accelerate(). So far, with these Model Color description, a blueprint for objects are ready but it Seats has not been created yet. To create the objects, we need to follow the following syntax: <className><objectName>; Start() For example; Stop() car c1; Accelerate() Here, car is the classname and c1 is the object name. Class vs Objects
Class Object
Class is a data type Object is an instance of class data type
It generates objects It gives life to a class
It is the prototype or the model It is an entity where class definitions apply
It doesn’t occupy memory It occupies memory
It can’t be manipulated for its not available in It can be manipulated.