OBJECT ORIENTED PROGRAMMING (OOP)
An object oriented programming is a modular approach (breaking the program into small
modules or parts), which allows the data to be applied within stipulated program area. It also
provides reusability features to develop productive logic. OPP gives more emphasis on data.
Features of OOP :-
It gives stress on data item rather than functions
It makes the complete program simpler by dividing it into number of modules.
The object can be used as a bridge to have data flow from one function to another.
The data of an object can be accessed through functions associated with that object only
thus enhancing the security of the program.
New data and function can be easily added.
Basic elements/Principles of OOP :-
1) Object :- An identifiable entity having unique Characteristics (data) and behavior
(functions).
2) Class :- A class is a set of similar objects. Each object of a class contains similar
characteristics and behavior.
3) Abstraction :- The act of representing the essential features without knowing the
background details.
4) Encapsulation :- The wrapping up of data and its associated functions into a single unit
is known as encapsulation. It is a way of implementing abstraction.
5) Inheritance :- It is a method of inheriting the properties (data and functions) of one class
into another. The class from which the properties are inherited is called base class and the
class which inherits the properties are called derived class.
6) Polymorphism :- Polymorphism is the process of using a function for more than one
purpose. It is an ability of using a thing for more than one form.
7) Dynamic Binding :- The process of linking the function call with function signature
during the execution of the program is called Dynamic Binding.
8) Data Hiding :- The data in the program can be accessed only through its associated
objects and functions.
Benefits of OOPs :-
The use of existing class can be extended through inheritance.
Secured program are written using the concept of data hiding.
Multiple objects can be generated to co-exist without any interference.
Complex program are simplified by breaking it into number of modules.
Class is a User-Defined / Composite data type :-
Class is derived from primitive data types which combines the data and method as an integrated
components. The size of memory space allocated for the class is not pre-defined rather it depends
upon the description of the class specified by user.
Class, a blueprint of an object :-
Class is a prototype of an object. Each object belonging to a specific class possess the data and
methods defined within the class. It produces objects of similar types.
Class as Object Factory :-
A class contains all statements needed to create an object, its attributes/characteristics as well as
statement describing operations that object will be able to perform. Multiple objects can be
created from a class and hence a class is known as an object factory.
Object is an instance of a class :-
All the objects created with a given class have same structure and behavior but differ regarding
their state, hence object is an instance of a class. Creating an instance or an object of a class is
referred to as instantiating the class.
Encapsulation, a way of implementing Abstraction :-
Encapsulation i.e. wrapping up of data and functions into a single unit makes it possible to
concentrate only on the essential features with respect to the execution of the function by hiding
the background details of implementation.