Object, Class, Data, Encapsulation and Abstraction, Data Hiding, Inheritance, Polymorphism, Dynamic binding, Message Passing: Basic Concepts of Object Oriented Programming
Basic Concepts of Object Oriented Programming ,

1. Object
2. Class
3. Data Encapsulation
and Abstraction
4. Data Hiding
5. Inheritance
6. Polymorphism
7. Dynamic
binding
8. Message
Passing
1.Object: Objects are the basic run-time entities in an
object-oriented system. Programming problem is analyzed in terms of objects and
nature of communication between them. When a program is executed, objects
interact with each other by sending messages. Different objects can also interact
with each other without knowing the details of their data or code.
- An Object is an
Instance of a Class. An Instance is the existence in the computer system
by acquiring a memory space.
- An Object is the
only way a Class becomes usable.
- Objects are basis
of Object Oriented Programming.
- An Object has
all the Characteristics of the Class using which the Object is created.
- It implements
reusability of code written in Classes.
Object: student
DATA
Name
Date of
birth
FUNCTIONS
Total
Average
|
|
2. Classes:
A class is a
collection of objects of similar type. Once a class is defined, any number of
objects can be created which belong to that class. In fact, objects are
variables of the
type class. Once a class has been defined, we can create any number of objects
belonging to that class.
- A Class is a Blueprint
or Stencil for creating Objects.
- A Class
specifies all the Member Data and Member Functions that would be present
in the Objects created using the Class.
- Using a Class
any number of Objects can be created.
- It’s a User
Defined Data Type also called Abstract Data Type, which acts like a basic
data type when used.
- Usually
Classes are used to represent computer understandable formats for Real
World Entities.
3. Data Abstraction and Encapsulation
Abstraction
refers to the act of representing essential features without including the
background details or explanations. Classes use the concept of abstraction and
are defined as a list of abstract attributes. Storing data and functions in a
single unit (class) is encapsulation. Data cannot be accessible to the outside
world and only those functions which are stored in the class can access it.
Abstraction :-
- It’s the process
of Hiding the complexities of implementation and providing a simple
Interface for easy use.
- Its implemented
using Encapsulation.
- Functions,
Structures and Classes implement Abstraction at programmer level.
Encapsulation
:-
- It’s the process
of wrapping up of Data and Functions inside a single Entity (usually
Classes).
- Encapsulation
helps to establish Abstraction and Data Hiding.
- Functions,
Structures and Classes implement Encapsulation at programmer level.
5. Data Hiding
:-
It’s the process of keeping the Data under
such an Access mode that its only accessible to permitted Functions.Using
Private, Protected specifiers, we can hide Data from access from outside a
Class. Functions, Structures
and Classes implement Data Hiding at programmer level.
6. Inheritance
Inheritance is the process by which objects can acquire
the properties of objects of other class. In OOP, inheritance provides
reusability, like, adding additional features to an existing class without
modifying it. This is achieved by deriving a new class from the existing one.
The new class will have combined features of both the classes.
- Here the Class
which gets the Inherited properties is called the Child Class and from
which it acquires the properties is called the Base or Parent Class.
- During
Inheritance the Protected and Public Data and Functions get passed on as
copies from the Parent or Base Classes to Child Classes.
- It forms a
Hierarchical Structure from Parent down to Children Classes.
- It implements
Reusability of Parent Class Data and Functions.
- Structures and
Classes can be used to implement Inheritance.
- Types
:- Single, Multilevel, Multiple, Hierarchical and Hybrid.
7. Polymorphism
Polymorphism means the ability to take more than one
form. An operation may exhibit different behaviors in different instances. The
behavior depends on the data types used in the operation. Polymorphism is
extensively used in implementing Inheritance using same
name with either Different number of Arguments or Different Data types of
Arguments.
Types:-
Compile Time (the compiler recognizes the binding between the function and its
code during compile time) and Run Time(the compiler recognizes the binding
between the function and its code during runtime)
8. Dynamic binding :-
- Its also called
Runtime Polymorphism, where the compiler recognizes the binding between
the function and its code during runtime.
- Its implemented
using Virtual Functions, during Inheritance.
9. Message Passing :-
- It’s the process
of passing Data between Objects of same Class and also of different
Classes.
- Its implemented
using Function calling or by simply sharing data.
- Types:- From
User to Objects (done by invoking Function inside an Object) and From
Object to Object (by sharing Data of one Object with another Object).
- Using Friend
functions (with objects as input arguments), message passing can be done
between two or more Objects of Different Classes.
- Using member
Functions (with objects as input arguments), message passing can be done
between objects of same Class.