SlideShare a Scribd company logo
© Prognoz Technologies Pvt. Ltd
Encapsulation
© Prognoz Technologies Pvt. Ltd
OOP
Encapsulation
Inheritance
Polymorphism
Abstraction
4 pillars of OOPS
© Prognoz Technologies Pvt. Ltd
Encapsulation
 Hiding implementation details of an object from its clients.
 Encapsulation provides abstraction.
 separates external view (behavior) from internal view (state)
 Encapsulation protects the integrity of an object's data.
© Prognoz Technologies Pvt. Ltd
Defining Encapsulation
4
 Encapsulation is the process of hiding an object’s implementation from another object, while
presenting only the interfaces that should be visible.
 An encapsulated object can be thought of as a black box or an abstraction.
 Its inner workings are hidden to the client, which only invokes the interface methods.
A=10
B=10
C=20
Addition
© Prognoz Technologies Pvt. Ltd
1st Principles of Encapsulation
“Don’t ask how I do it, but this is what I can do”
- The encapsulated object
5
How this thing
sending message?
© Prognoz Technologies Pvt. Ltd
2nd Principles of Encapsulation
“I don’t care how, just do your job, and I’ll do mine”
- One encapsulated object to another
6
© Prognoz Technologies Pvt. Ltd
Encapsulating a Class
 Members of a class must always be declared with the minimum level of visibility.
 Provide setters and getters (also known as accessors/mutators) to allow controlled access to
private data.
 Provide other public methods (known as interfaces ) that other objects must adhere to in order
to interact with the object.
7
Setters and Getters
private char sex;
public void setSex(char s) {
// validate here
sex = s;
}
public char getSex() {
// format here
return sex;
}
 Setters are methods that (only) alter the state of an object
 Getters are methods that (only) return information about the state of an object
© Prognoz Technologies Pvt. Ltd
Example
9
© Prognoz Technologies Pvt. Ltd
Benefits of encapsulation
 Provides abstraction between an object and its clients.
 Protects an object from unwanted access by clients.
Ex: A bank app forbids a client to change an Account's balance.
© Prognoz Technologies Pvt. Ltd
Thank you!!
11

More Related Content

PPTX
Object Oriented Programming
PPT
Lecture 2
PPT
PDF
4 pillars of OOPS CONCEPT
PPTX
Object oriented programming concept
PPTX
concept of oops
PPTX
Object Oriented Programming
PPT
Object Oriented Concepts and Principles
Object Oriented Programming
Lecture 2
4 pillars of OOPS CONCEPT
Object oriented programming concept
concept of oops
Object Oriented Programming
Object Oriented Concepts and Principles

What's hot (20)

PPTX
Object Oriented Programming Concepts
PPT
Object Oriented Language
PPTX
Variables in python
PDF
Object Oriented Concepts in Real Projects
PPT
Object Oriented Programming Concepts using Java
PPTX
Basic Concepts of OOPs (Object Oriented Programming in Java)
PPTX
Oops concept in c++ unit 3 -topic 4
PPTX
Oops concepts
PPTX
the Concept of Object-Oriented Programming
PDF
Object oriented concepts
PPT
C plusplus
PPTX
Std 12 computer chapter 6 object oriented concepts (part 1)
PPTX
object oriented programing lecture 1
PPTX
Object oriented programming
PDF
Oops concepts || Object Oriented Programming Concepts in Java
PPTX
Introduction to OOP concepts
PPTX
Object-oriented programming
PPT
Object Oriented Programming In .Net
PDF
Concepts of OOPs
Object Oriented Programming Concepts
Object Oriented Language
Variables in python
Object Oriented Concepts in Real Projects
Object Oriented Programming Concepts using Java
Basic Concepts of OOPs (Object Oriented Programming in Java)
Oops concept in c++ unit 3 -topic 4
Oops concepts
the Concept of Object-Oriented Programming
Object oriented concepts
C plusplus
Std 12 computer chapter 6 object oriented concepts (part 1)
object oriented programing lecture 1
Object oriented programming
Oops concepts || Object Oriented Programming Concepts in Java
Introduction to OOP concepts
Object-oriented programming
Object Oriented Programming In .Net
Concepts of OOPs
Ad

Viewers also liked (18)

PPTX
Interesting Concept of Object Oriented Programming
PPTX
Object Oriented Programming Concepts
PDF
Oops (inheritance&interface)
PPT
Abstrac tinheritance polymorphism
PDF
javainterface
PPSX
Java Object Oriented Programming
PPT
Advanced OOP - Laws, Principles, Idioms
PPT
Design patterns - Abstract Factory Pattern
PDF
String handling(string class)
PPT
Java Programming - Abstract Class and Interface
PDF
Java Inheritance
PPTX
Java interview questions 2
PPTX
Design pattern (Abstract Factory & Singleton)
PPT
Java: Inheritance
PPTX
Encapsulation
PPTX
oops concept in java | object oriented programming in java
PPT
20. Object-Oriented Programming Fundamental Principles
PPTX
encapsulation, inheritance, overriding, overloading
Interesting Concept of Object Oriented Programming
Object Oriented Programming Concepts
Oops (inheritance&interface)
Abstrac tinheritance polymorphism
javainterface
Java Object Oriented Programming
Advanced OOP - Laws, Principles, Idioms
Design patterns - Abstract Factory Pattern
String handling(string class)
Java Programming - Abstract Class and Interface
Java Inheritance
Java interview questions 2
Design pattern (Abstract Factory & Singleton)
Java: Inheritance
Encapsulation
oops concept in java | object oriented programming in java
20. Object-Oriented Programming Fundamental Principles
encapsulation, inheritance, overriding, overloading
Ad

Similar to Concept of Object Oriented Programming (20)

PDF
Java Day-2
PPTX
Presentation - Copy no vaperpoit asd.pptx
PPTX
Abstraction file
PPTX
Abstraction file
PPTX
Abstraction file
PPTX
Abstraction file
PPTX
Abstraction file
PPTX
Abstraction file
PPTX
Abstraction file
PPTX
Presentation - 001jasfcjedhfuj5454545.pptx
PPTX
Lecture 2
PPT
01_Enterprise_Applications_RIO.ppt
PPTX
Presen5416846534653416354165341864adeadvdes
PPTX
Prese00z213hfcyudegtyfwyyudeqw7tgfi7u.pptx
PPT
Object oriented vs. object based programming
PPTX
Presentation related to Encapsulation and OOPs
PPTX
Proxy Design Pattern
PPTX
Ppt on innovation of oop's language
PPT
JAVA design patterns and Basic OOp concepts
PDF
Object-oriented design principles
Java Day-2
Presentation - Copy no vaperpoit asd.pptx
Abstraction file
Abstraction file
Abstraction file
Abstraction file
Abstraction file
Abstraction file
Abstraction file
Presentation - 001jasfcjedhfuj5454545.pptx
Lecture 2
01_Enterprise_Applications_RIO.ppt
Presen5416846534653416354165341864adeadvdes
Prese00z213hfcyudegtyfwyyudeqw7tgfi7u.pptx
Object oriented vs. object based programming
Presentation related to Encapsulation and OOPs
Proxy Design Pattern
Ppt on innovation of oop's language
JAVA design patterns and Basic OOp concepts
Object-oriented design principles

More from Prognoz Technologies Pvt. Ltd. (9)

PPTX
Introduction to package in java
PPSX
A comprehensive software infrastructure of .Net
PPSX
Microsoft C# programming basics
PPTX
Introduction of .net framework
PPSX
How to handle exceptions in Java Technology
PPSX
Features of java technology
PPTX
Basic concept of Object Oriented Programming
PPSX
Qualities of a Successful Person
PDF
Quantitative Aptitude Concepts
Introduction to package in java
A comprehensive software infrastructure of .Net
Microsoft C# programming basics
Introduction of .net framework
How to handle exceptions in Java Technology
Features of java technology
Basic concept of Object Oriented Programming
Qualities of a Successful Person
Quantitative Aptitude Concepts

Recently uploaded (20)

PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PPTX
Lecture Notes Electrical Wiring System Components
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PPTX
additive manufacturing of ss316l using mig welding
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PDF
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PDF
PPT on Performance Review to get promotions
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PPTX
Internet of Things (IOT) - A guide to understanding
PDF
Model Code of Practice - Construction Work - 21102022 .pdf
PDF
Well-logging-methods_new................
PPTX
UNIT 4 Total Quality Management .pptx
PPT
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
PDF
Digital Logic Computer Design lecture notes
PPT
Project quality management in manufacturing
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PPTX
web development for engineering and engineering
PPTX
OOP with Java - Java Introduction (Basics)
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
Lecture Notes Electrical Wiring System Components
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
additive manufacturing of ss316l using mig welding
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PPT on Performance Review to get promotions
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
Embodied AI: Ushering in the Next Era of Intelligent Systems
Internet of Things (IOT) - A guide to understanding
Model Code of Practice - Construction Work - 21102022 .pdf
Well-logging-methods_new................
UNIT 4 Total Quality Management .pptx
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
Digital Logic Computer Design lecture notes
Project quality management in manufacturing
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
web development for engineering and engineering
OOP with Java - Java Introduction (Basics)

Concept of Object Oriented Programming

  • 1. © Prognoz Technologies Pvt. Ltd Encapsulation
  • 2. © Prognoz Technologies Pvt. Ltd OOP Encapsulation Inheritance Polymorphism Abstraction 4 pillars of OOPS
  • 3. © Prognoz Technologies Pvt. Ltd Encapsulation  Hiding implementation details of an object from its clients.  Encapsulation provides abstraction.  separates external view (behavior) from internal view (state)  Encapsulation protects the integrity of an object's data.
  • 4. © Prognoz Technologies Pvt. Ltd Defining Encapsulation 4  Encapsulation is the process of hiding an object’s implementation from another object, while presenting only the interfaces that should be visible.  An encapsulated object can be thought of as a black box or an abstraction.  Its inner workings are hidden to the client, which only invokes the interface methods. A=10 B=10 C=20 Addition
  • 5. © Prognoz Technologies Pvt. Ltd 1st Principles of Encapsulation “Don’t ask how I do it, but this is what I can do” - The encapsulated object 5 How this thing sending message?
  • 6. © Prognoz Technologies Pvt. Ltd 2nd Principles of Encapsulation “I don’t care how, just do your job, and I’ll do mine” - One encapsulated object to another 6
  • 7. © Prognoz Technologies Pvt. Ltd Encapsulating a Class  Members of a class must always be declared with the minimum level of visibility.  Provide setters and getters (also known as accessors/mutators) to allow controlled access to private data.  Provide other public methods (known as interfaces ) that other objects must adhere to in order to interact with the object. 7
  • 8. Setters and Getters private char sex; public void setSex(char s) { // validate here sex = s; } public char getSex() { // format here return sex; }  Setters are methods that (only) alter the state of an object  Getters are methods that (only) return information about the state of an object
  • 9. © Prognoz Technologies Pvt. Ltd Example 9
  • 10. © Prognoz Technologies Pvt. Ltd Benefits of encapsulation  Provides abstraction between an object and its clients.  Protects an object from unwanted access by clients. Ex: A bank app forbids a client to change an Account's balance.
  • 11. © Prognoz Technologies Pvt. Ltd Thank you!! 11