Object Oriented Programming
- Object Oriented Programming(OOP) is a programming technique on which programs are written on the basis of objects.
- An Object is a collection of data and functions.
- Object may represent a person, thing, or place in real world.
- In OOP, data and all possible functions on data are grouped together.
- Object-Oriented Programs are easier to learn and modify.
- Object Oriented Programming is powerful technique to develop software. It is used to analyze and design the application in terms of objects.
- It deals with data and procedures that process the data as a single object.
- Some of the object-oriented languages that have been develped are:
- C++
- Smalltalk
- Eiffel
- CLOS
- Java
Features Of OOP
Following are the features of OOP
- Objects
- Real-world Modelling
- Reusability
- Information Hiding
Real-World Modelling
- OOP is based on real-world modeling.
- As in real world, things have properties and working capabilities. Similarly, objects have data and functions.
- Data represents properties and
- Functions represents working of objects.
Reusability
- OOP provides ways of reusing the data and code.
- Inheritance is a technique that allows a programmer to use the code of existing program to create new program.
Information Hiding
- OOP allows the programmer to hide important data from the user, it is performed by encapsulation.
Polymorphism
- Polymorphism is an ability of an object to behave in multiple ways.
Objects
- An Object represent an entity in the real world such as person, things or concept etc.
- An object is defined by its name.
- An object consist of the following two things:
- Properties: Properties are the characteristics of an object.
- Functions: Functions are the actions that can be performed by an object.
Examples:
Some examples of different types are as follows:
- Physical Objects
- Vehicles such as car, bus truck etc.
- Electrical Components
- Elements of Computer User Environment
- Windows
- Menus Graphic Objects
- Mouse and Keyboard
- User Defined Data Types
- Time
- Angles
- Physical Objects
Properties Of Objects
- The characteristics of an objects are known as its properties or attributes.
- Each Object has its own properties. These properties can be used to describe the object.
Example:
- The properties of an object Person can be follows:
- Name
- Age
- Height
- The properties of an object Car can be follows:
- Color
- Price
- Model
- Engine Power
- The properties of an object Person can be follows:
- The set of values of the attributes of a particular object is called its state. It means that the state of object can be determined by the values of its attributes.
- Following figure shows the value of the attributes of an Object Car.
Functions Of Object:
- An Object can Perform task and actions.
- The actions that can be performed by an object are known as functions or methods
Example
- The object car can perform the following functions:
- Start
- Stop
- Accelerate
- Reverse
- The object car can perform the following functions:
- The set of all functions of an object represents the behavior of an object. It means that the overall behavior of an object can be determined by the list of functions of the object.
