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

What's hot (20)

PPTX
Object Oriented Programming Concepts
Abhigyan Singh Yadav
 
PPT
Object Oriented Language
dheva B
 
PPTX
Variables in python
Jaya Kumari
 
PDF
Object Oriented Concepts in Real Projects
EPAM
 
PPT
Object Oriented Programming Concepts using Java
Glenn Guden
 
PPTX
Basic Concepts of OOPs (Object Oriented Programming in Java)
Michelle Anne Meralpis
 
PPTX
Oops concept in c++ unit 3 -topic 4
MOHIT TOMAR
 
PPTX
Oops concepts
Kanan Gandhi
 
PPTX
the Concept of Object-Oriented Programming
Aida Ramlan II
 
PDF
Object oriented concepts
Pranali Chaudhari
 
PPT
C plusplus
Niti Bansal
 
PPTX
Std 12 computer chapter 6 object oriented concepts (part 1)
Nuzhat Memon
 
PPTX
object oriented programing lecture 1
Geophery sanga
 
PPTX
Object oriented programming
Amit Soni (CTFL)
 
PDF
Oops concepts || Object Oriented Programming Concepts in Java
Madishetty Prathibha
 
PPTX
Introduction to OOP concepts
Ahmed Farag
 
PPTX
Object-oriented programming
Neelesh Shukla
 
PPT
Object Oriented Programming In .Net
Greg Sohl
 
PDF
Concepts of OOPs
Essay Corp
 
Object Oriented Programming Concepts
Abhigyan Singh Yadav
 
Object Oriented Language
dheva B
 
Variables in python
Jaya Kumari
 
Object Oriented Concepts in Real Projects
EPAM
 
Object Oriented Programming Concepts using Java
Glenn Guden
 
Basic Concepts of OOPs (Object Oriented Programming in Java)
Michelle Anne Meralpis
 
Oops concept in c++ unit 3 -topic 4
MOHIT TOMAR
 
Oops concepts
Kanan Gandhi
 
the Concept of Object-Oriented Programming
Aida Ramlan II
 
Object oriented concepts
Pranali Chaudhari
 
C plusplus
Niti Bansal
 
Std 12 computer chapter 6 object oriented concepts (part 1)
Nuzhat Memon
 
object oriented programing lecture 1
Geophery sanga
 
Object oriented programming
Amit Soni (CTFL)
 
Oops concepts || Object Oriented Programming Concepts in Java
Madishetty Prathibha
 
Introduction to OOP concepts
Ahmed Farag
 
Object-oriented programming
Neelesh Shukla
 
Object Oriented Programming In .Net
Greg Sohl
 
Concepts of OOPs
Essay Corp
 

Viewers also liked (18)

PPTX
Interesting Concept of Object Oriented Programming
Prognoz Technologies Pvt. Ltd.
 
PPTX
Object Oriented Programming Concepts
Mohamed Emam
 
PDF
Oops (inheritance&interface)
Muthukumaran Subramanian
 
PPT
Abstrac tinheritance polymorphism
Hoang Nguyen
 
PDF
javainterface
Arjun Shanka
 
PPSX
Java Object Oriented Programming
University of Potsdam
 
PPT
Advanced OOP - Laws, Principles, Idioms
Clint Edmonson
 
PPT
Design patterns - Abstract Factory Pattern
Annamalai Chockalingam
 
PDF
String handling(string class)
Ravi Kant Sahu
 
PPT
Java Programming - Abstract Class and Interface
Oum Saokosal
 
PDF
Java Inheritance
Rosie Jane Enomar
 
PPTX
Java interview questions 2
Sherihan Anver
 
PPTX
Design pattern (Abstract Factory & Singleton)
paramisoft
 
PPT
Java: Inheritance
Tareq Hasan
 
PPTX
Encapsulation
Githushan Gengaparam
 
PPTX
oops concept in java | object oriented programming in java
CPD INDIA
 
PPT
20. Object-Oriented Programming Fundamental Principles
Intro C# Book
 
PPTX
encapsulation, inheritance, overriding, overloading
Shivam Singhal
 
Interesting Concept of Object Oriented Programming
Prognoz Technologies Pvt. Ltd.
 
Object Oriented Programming Concepts
Mohamed Emam
 
Oops (inheritance&interface)
Muthukumaran Subramanian
 
Abstrac tinheritance polymorphism
Hoang Nguyen
 
javainterface
Arjun Shanka
 
Java Object Oriented Programming
University of Potsdam
 
Advanced OOP - Laws, Principles, Idioms
Clint Edmonson
 
Design patterns - Abstract Factory Pattern
Annamalai Chockalingam
 
String handling(string class)
Ravi Kant Sahu
 
Java Programming - Abstract Class and Interface
Oum Saokosal
 
Java Inheritance
Rosie Jane Enomar
 
Java interview questions 2
Sherihan Anver
 
Design pattern (Abstract Factory & Singleton)
paramisoft
 
Java: Inheritance
Tareq Hasan
 
Encapsulation
Githushan Gengaparam
 
oops concept in java | object oriented programming in java
CPD INDIA
 
20. Object-Oriented Programming Fundamental Principles
Intro C# Book
 
encapsulation, inheritance, overriding, overloading
Shivam Singhal
 
Ad

Similar to Concept of Object Oriented Programming (20)

PDF
Java Day-2
People Strategists
 
PPTX
Presentation - Copy no vaperpoit asd.pptx
RajshreePathir
 
PPTX
Abstraction file
Luis Goldster
 
PPTX
Abstraction file
Hoang Nguyen
 
PPTX
Abstraction file
Harry Potter
 
PPTX
Abstraction file
Fraboni Ec
 
PPTX
Abstraction file
Young Alista
 
PPTX
Abstraction file
James Wong
 
PPTX
Abstraction file
Tony Nguyen
 
PPTX
Presentation - 001jasfcjedhfuj5454545.pptx
RajshreePathir
 
PPTX
Lecture 2
talha ijaz
 
PPT
01_Enterprise_Applications_RIO.ppt
Ponnieaswari M.S
 
PPTX
Presen5416846534653416354165341864adeadvdes
RajshreePathir
 
PPTX
Prese00z213hfcyudegtyfwyyudeqw7tgfi7u.pptx
RajshreePathir
 
PPT
Object oriented vs. object based programming
Mohammad Kamrul Hasan
 
PPTX
Presentation related to Encapsulation and OOPs
vinitsinghthakur46
 
PPTX
Proxy Design Pattern
Anjan Kumar Bollam
 
PPTX
Ppt on innovation of oop's language
Krishna Gupta
 
PPT
JAVA design patterns and Basic OOp concepts
Rahul Malhotra
 
PDF
Object-oriented design principles
Xiaoyan Chen
 
Java Day-2
People Strategists
 
Presentation - Copy no vaperpoit asd.pptx
RajshreePathir
 
Abstraction file
Luis Goldster
 
Abstraction file
Hoang Nguyen
 
Abstraction file
Harry Potter
 
Abstraction file
Fraboni Ec
 
Abstraction file
Young Alista
 
Abstraction file
James Wong
 
Abstraction file
Tony Nguyen
 
Presentation - 001jasfcjedhfuj5454545.pptx
RajshreePathir
 
Lecture 2
talha ijaz
 
01_Enterprise_Applications_RIO.ppt
Ponnieaswari M.S
 
Presen5416846534653416354165341864adeadvdes
RajshreePathir
 
Prese00z213hfcyudegtyfwyyudeqw7tgfi7u.pptx
RajshreePathir
 
Object oriented vs. object based programming
Mohammad Kamrul Hasan
 
Presentation related to Encapsulation and OOPs
vinitsinghthakur46
 
Proxy Design Pattern
Anjan Kumar Bollam
 
Ppt on innovation of oop's language
Krishna Gupta
 
JAVA design patterns and Basic OOp concepts
Rahul Malhotra
 
Object-oriented design principles
Xiaoyan Chen
 
Ad

More from Prognoz Technologies Pvt. Ltd. (9)

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

Recently uploaded (20)

PDF
Basic_Concepts_in_Clinical_Biochemistry_2018كيمياء_عملي.pdf
AdelLoin
 
PDF
Biomechanics of Gait: Engineering Solutions for Rehabilitation (www.kiu.ac.ug)
publication11
 
PDF
GTU Civil Engineering All Semester Syllabus.pdf
Vimal Bhojani
 
PPTX
The Role of Information Technology in Environmental Protectio....pptx
nallamillisriram
 
PDF
Zilliz Cloud Demo for performance and scale
Zilliz
 
PPTX
Worm gear strength and wear calculation as per standard VB Bhandari Databook.
shahveer210504
 
PPTX
artificial intelligence applications in Geomatics
NawrasShatnawi1
 
PPT
PPT2_Metal formingMECHANICALENGINEEIRNG .ppt
Praveen Kumar
 
PPTX
Damage of stability of a ship and how its change .pptx
ehamadulhaque
 
PPTX
GitOps_Without_K8s_Training_detailed git repository
DanialHabibi2
 
PPTX
Depth First Search Algorithm in 🧠 DFS in Artificial Intelligence (AI)
rafeeqshaik212002
 
PPTX
Thermal runway and thermal stability.pptx
godow93766
 
PDF
MAD Unit - 2 Activity and Fragment Management in Android (Diploma IT)
JappanMavani
 
PPTX
Evaluation and thermal analysis of shell and tube heat exchanger as per requi...
shahveer210504
 
PPTX
Shinkawa Proposal to meet Vibration API670.pptx
AchmadBashori2
 
PPTX
Element 11. ELECTRICITY safety and hazards
merrandomohandas
 
PPTX
原版一样(Acadia毕业证书)加拿大阿卡迪亚大学毕业证办理方法
Taqyea
 
PPTX
Introduction to Design of Machine Elements
PradeepKumarS27
 
PPTX
Hashing Introduction , hash functions and techniques
sailajam21
 
PPTX
Lecture 1 Shell and Tube Heat exchanger-1.pptx
mailforillegalwork
 
Basic_Concepts_in_Clinical_Biochemistry_2018كيمياء_عملي.pdf
AdelLoin
 
Biomechanics of Gait: Engineering Solutions for Rehabilitation (www.kiu.ac.ug)
publication11
 
GTU Civil Engineering All Semester Syllabus.pdf
Vimal Bhojani
 
The Role of Information Technology in Environmental Protectio....pptx
nallamillisriram
 
Zilliz Cloud Demo for performance and scale
Zilliz
 
Worm gear strength and wear calculation as per standard VB Bhandari Databook.
shahveer210504
 
artificial intelligence applications in Geomatics
NawrasShatnawi1
 
PPT2_Metal formingMECHANICALENGINEEIRNG .ppt
Praveen Kumar
 
Damage of stability of a ship and how its change .pptx
ehamadulhaque
 
GitOps_Without_K8s_Training_detailed git repository
DanialHabibi2
 
Depth First Search Algorithm in 🧠 DFS in Artificial Intelligence (AI)
rafeeqshaik212002
 
Thermal runway and thermal stability.pptx
godow93766
 
MAD Unit - 2 Activity and Fragment Management in Android (Diploma IT)
JappanMavani
 
Evaluation and thermal analysis of shell and tube heat exchanger as per requi...
shahveer210504
 
Shinkawa Proposal to meet Vibration API670.pptx
AchmadBashori2
 
Element 11. ELECTRICITY safety and hazards
merrandomohandas
 
原版一样(Acadia毕业证书)加拿大阿卡迪亚大学毕业证办理方法
Taqyea
 
Introduction to Design of Machine Elements
PradeepKumarS27
 
Hashing Introduction , hash functions and techniques
sailajam21
 
Lecture 1 Shell and Tube Heat exchanger-1.pptx
mailforillegalwork
 

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