0% found this document useful (0 votes)
38 views16 pages

Encapsulation

Uploaded by

Triziah Acosta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views16 pages

Encapsulation

Uploaded by

Triziah Acosta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 16

OBJECTIVES

At the end of the lesson the students are


expected to:
a. Constructs a class that contains multiple
option for object construction
b. Know what is the use of encapsulation
c. Create a programmer defined method in a
program
If you are taking vitamins, is it complete?

When you are sick, what medicine you are taking?


ACTIVITY

Got Talent
Steps:
1.Create and name a group of 10.
2. In 10 minutes, meet with the group and share
what talent you posses. The more the merrier.
3.Present/perform your talent in 2 minute-
time(all-in)
WHAT IS ENCAPSULATION?

In OOP terms, a class is the blueprint. Classes


are used to encapsulate instance variables
(data) and methods (behaviors) of an object.
Object can hide their implementation from
other objects (principle called information
hiding or encapsulation). Each class holds
both data and the set of methods that controls
the data.
The components for thee data members of a
class are called “instance variables or
member variables”. Classes are used to
incorporate objects that work together to
implement the system.
Encapsulation is the grouping of data,
functions, methods, and related properties
into a single
component. It makes easier to modify the
execution at a later date by allowing to hide
the implementation details of the objects.
This concept is known as data hiding.
Encapsulation is the hiding of data
implementation by restricting access to
accessors and mutators.
An accessor is a method that is used to ask an
object about itself. In OOP, these are usually in
the form of properties, which have a get
method, which is an accessor method.

accessor methods are not restricted to properties


and can be any public method that gives
information about the state of the object.
A Mutator is public method that is used to
modify the state of an object, while hiding the
implementation of exactly how the data gets
modified. It’s the set method that lets the
caller modify the member data behind the
scenes.
Hiding the internals of the object protects its
integrity by preventing users from setting the
internal data of the component into an invalid
or inconsistent state. This type of data
protection and implementation protection is
called Encapsulation.
A benefit of encapsulation is that it can reduce
system complexity.
Encapsulation example are the following:
POS system
Enrolment system
Banking system
And etc.
ASSESSMENT

____1.It is the grouping of data, functions, methods, and related


properties into a single component. It makes easier to modify
the execution at a later date by allowing to hide the
implementation details of the objects
____2. What is the concept used by encapsulation?
____3. Is a method that is used to ask an object about itself.
_____4. is public method that is used to modify the state of an
object, while hiding the implementation of exactly how the
data gets modified. It’s the set method that lets the caller modify
the member data behind the scenes
____ 5. What is the benefit of encapsulation?
ASSIGNMENT

Search a program that shows encapsulation.

You might also like