Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 11

DATA ENCAPSULATION

1
What are we doing today?

 Introduction of:
 OOPS
 3 IMPORTANT THINGS
 ENCAPSULATION
 ACCESS METHODS
 EXAMPLES

2
OBJECT ORIENTED PROGRAMMING

• It is the expanded version of C.


• It was developed by Bjarne Stroustrup on 1979 initially
called as C with class.
• OOP provides a clear modular structure for programs
which makes it good for defining abstract datatypes where
implementation details are hidden and the unit has a clearly
defined interface.
• OOP makes it easy to maintain and modify existing code
as new objects can be created with small differences to
existing ones
3
OBJECT

• It is an entiy in real world and a


device that support encapsulation.

• Identifying objects and assigning


responsibilities to these objects.
An object is like a
black box.
• Objects communicate to other
The internal objects by sending messages.
details are
hidden. • Messages are received by the
methods of an object

4
THREE IMPORTANT THINGS

• Encapsulation:
Sometimes referred to as data hiding, is the
mechanism whereby the implementation details of a class
are kept hidden from the user.
• Inheritance :
One object acquired the properties of other object.
• Polymorphism:
One interface multiple methods.

5
ENCAPSULATION

• It is the mechanism that binds together code and


data it manipulates,and keeps both safe from outside
interference and misuse.

• When code and data binds together in this fashion


,an object is created.

• It’s the process that allows selective hiding of


properties and methods in class.

6
ACCESS METHODS

• Private:
Objects accessed only inside the class.
• Public:
Objects accessed anywhere in the program.
• Protected:
Methods of the class only can access.

7
Encapsulation into the Protocol Layer

8
ADVANTAGES

• Keeping the state of an object.

• Change the implementation of an object

• Reuse of objects.

• The independence of each object.

9
Example

Student marks
Social Network Account
THANK YOU

11

You might also like