SlideShare a Scribd company logo
1 of 10
ABSTRACTION AND ENCAPSULATION
ABSTRACTION
- Ignoring those aspects of an object that are
not relevant to the current scope of the
problem.
- Reduces scope and helps managing
complexity.
ABSTRACTION
- Designing a website to sell new Cars.
Car
Description
Type
Price
…
ABSTRACTION
- Do I need to include Service History as a
field? No (Because it does not belong to new
car and is not relevant to current scope)
- Do I need to include Vehicle Registration
Number as a field? No (Because currently we
do not have and it’s not necessary currently.
You get the number after you buy the car.)
ABSTRACTION
EXCLUDE WHICH IS
NOT RELEVANT TO THE CURRENT SCOPE
ENCAPSULATION
- Provides interface to access the functionality of
the object & hides how it is implemented.
- Keep the attributes and behavior as one unit
– Helps to make it more independent.
ENCAPSULATION
- Example of Pressing ’A’ on Keyboard.
Keyboard
Press A --- 65
1000001
Laptop
ENCAPSULATION
- Keys are exposed as interface and as an end
user when I press ‘A’, it is printed on the screen.
I do not know how it is implemented.
- Implementation is hidden as to how it displays
that on screen.
- Hiding implementation has a benefit – you can
change the implementation later but you can still
have the same interface. Maintenance is easy.
ENCAPSULATION
- Other aspect of attributes and behavior as one
unit is it helps to make the object independent.
- As a programmer, you know when you press
A, 65 (ASCII) is sent as signal but for end user it
does not matter.
- 65 is hidden from end user and it is private to
Keyboard object, only inner methods have
access to it. This keeps them as one unit and
encapsulated.
CONCLUSION
- Abstraction comes before Encapsulation
- In Abstraction, we are trying to come up with
the scope of the problem.
- In Encapsulation, we are trying to come up
with the approach to solve and implement
problem in a better way.

More Related Content

What's hot

WHAT IS ABSTRACTION IN JAVA
WHAT IS ABSTRACTION IN JAVAWHAT IS ABSTRACTION IN JAVA
WHAT IS ABSTRACTION IN JAVAsivasundari6
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programmingAmit Soni (CTFL)
 
Oops concepts || Object Oriented Programming Concepts in Java
Oops concepts || Object Oriented Programming Concepts in JavaOops concepts || Object Oriented Programming Concepts in Java
Oops concepts || Object Oriented Programming Concepts in JavaMadishetty Prathibha
 
Abstraction java
Abstraction javaAbstraction java
Abstraction javaMahinImran
 
Java abstract class & abstract methods
Java abstract class & abstract methodsJava abstract class & abstract methods
Java abstract class & abstract methodsShubham Dwivedi
 
java interface and packages
java interface and packagesjava interface and packages
java interface and packagesVINOTH R
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented ProgrammingIqra khalil
 
Class and object in C++
Class and object in C++Class and object in C++
Class and object in C++rprajat007
 
classes and objects in C++
classes and objects in C++classes and objects in C++
classes and objects in C++HalaiHansaika
 
Learn C# Programming - Encapsulation & Methods
Learn C# Programming - Encapsulation & MethodsLearn C# Programming - Encapsulation & Methods
Learn C# Programming - Encapsulation & MethodsEng Teong Cheah
 
Friend function & friend class
Friend function & friend classFriend function & friend class
Friend function & friend classAbhishek Wadhwa
 
Need of object oriented programming
Need of object oriented programmingNeed of object oriented programming
Need of object oriented programmingAmar Jukuntla
 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++Vineeta Garg
 
OOP - Understanding association, aggregation, composition and dependency
OOP - Understanding association, aggregation, composition and dependencyOOP - Understanding association, aggregation, composition and dependency
OOP - Understanding association, aggregation, composition and dependencyMudasir Qazi
 
Classes and objects
Classes and objectsClasses and objects
Classes and objectsAnil Kumar
 
friend function(c++)
friend function(c++)friend function(c++)
friend function(c++)Ritika Sharma
 

What's hot (20)

WHAT IS ABSTRACTION IN JAVA
WHAT IS ABSTRACTION IN JAVAWHAT IS ABSTRACTION IN JAVA
WHAT IS ABSTRACTION IN JAVA
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
Oops concepts || Object Oriented Programming Concepts in Java
Oops concepts || Object Oriented Programming Concepts in JavaOops concepts || Object Oriented Programming Concepts in Java
Oops concepts || Object Oriented Programming Concepts in Java
 
Abstraction java
Abstraction javaAbstraction java
Abstraction java
 
encapsulation
encapsulationencapsulation
encapsulation
 
JVM
JVMJVM
JVM
 
Java abstract class & abstract methods
Java abstract class & abstract methodsJava abstract class & abstract methods
Java abstract class & abstract methods
 
java interface and packages
java interface and packagesjava interface and packages
java interface and packages
 
C# Access modifiers
C# Access modifiersC# Access modifiers
C# Access modifiers
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented Programming
 
Class and object in C++
Class and object in C++Class and object in C++
Class and object in C++
 
classes and objects in C++
classes and objects in C++classes and objects in C++
classes and objects in C++
 
concept of oops
concept of oopsconcept of oops
concept of oops
 
Learn C# Programming - Encapsulation & Methods
Learn C# Programming - Encapsulation & MethodsLearn C# Programming - Encapsulation & Methods
Learn C# Programming - Encapsulation & Methods
 
Friend function & friend class
Friend function & friend classFriend function & friend class
Friend function & friend class
 
Need of object oriented programming
Need of object oriented programmingNeed of object oriented programming
Need of object oriented programming
 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++
 
OOP - Understanding association, aggregation, composition and dependency
OOP - Understanding association, aggregation, composition and dependencyOOP - Understanding association, aggregation, composition and dependency
OOP - Understanding association, aggregation, composition and dependency
 
Classes and objects
Classes and objectsClasses and objects
Classes and objects
 
friend function(c++)
friend function(c++)friend function(c++)
friend function(c++)
 

Viewers also liked

c# training | c# training videos | c# object oriented programming | c# course
c# training | c# training videos | c# object oriented programming | c# coursec# training | c# training videos | c# object oriented programming | c# course
c# training | c# training videos | c# object oriented programming | c# courseNancy Thomas
 
Var vs iEnumerable
Var vs iEnumerableVar vs iEnumerable
Var vs iEnumerableUmar Ali
 
Object Oriented Programming with C#
Object Oriented Programming with C#Object Oriented Programming with C#
Object Oriented Programming with C#foreverredpb
 
DATATYPE IN C# CSHARP.net
DATATYPE IN C# CSHARP.netDATATYPE IN C# CSHARP.net
DATATYPE IN C# CSHARP.netSireesh K
 
Classes and Objects In C# With Example
Classes and Objects In C# With ExampleClasses and Objects In C# With Example
Classes and Objects In C# With ExampleCheezy Code
 
Learn Concept of Class and Object in C# Part 3
Learn Concept of Class and Object in C#  Part 3Learn Concept of Class and Object in C#  Part 3
Learn Concept of Class and Object in C# Part 3C# Learning Classes
 
introduction to c #
introduction to c #introduction to c #
introduction to c #Sireesh K
 
.NET Platform. C# Basics
.NET Platform. C# Basics.NET Platform. C# Basics
.NET Platform. C# Basicseleksdev
 
Unit Testing, TDD and ATDD
Unit Testing, TDD and ATDDUnit Testing, TDD and ATDD
Unit Testing, TDD and ATDDArnon Axelrod
 
Advanced C#. Part 1
Advanced C#. Part 1Advanced C#. Part 1
Advanced C#. Part 1eleksdev
 

Viewers also liked (20)

Array y Objects C#
Array y Objects C#Array y Objects C#
Array y Objects C#
 
c# training | c# training videos | c# object oriented programming | c# course
c# training | c# training videos | c# object oriented programming | c# coursec# training | c# training videos | c# object oriented programming | c# course
c# training | c# training videos | c# object oriented programming | c# course
 
Databases
DatabasesDatabases
Databases
 
Var vs iEnumerable
Var vs iEnumerableVar vs iEnumerable
Var vs iEnumerable
 
Object Oriented Programming with C#
Object Oriented Programming with C#Object Oriented Programming with C#
Object Oriented Programming with C#
 
DATATYPE IN C# CSHARP.net
DATATYPE IN C# CSHARP.netDATATYPE IN C# CSHARP.net
DATATYPE IN C# CSHARP.net
 
Generics collections
Generics collectionsGenerics collections
Generics collections
 
Objects and Types C#
Objects and Types C#Objects and Types C#
Objects and Types C#
 
Classes and Objects In C# With Example
Classes and Objects In C# With ExampleClasses and Objects In C# With Example
Classes and Objects In C# With Example
 
Modern pptx
Modern pptxModern pptx
Modern pptx
 
Collections in-csharp
Collections in-csharpCollections in-csharp
Collections in-csharp
 
C# in depth
C# in depthC# in depth
C# in depth
 
Learn Concept of Class and Object in C# Part 3
Learn Concept of Class and Object in C#  Part 3Learn Concept of Class and Object in C#  Part 3
Learn Concept of Class and Object in C# Part 3
 
Generics C#
Generics C#Generics C#
Generics C#
 
C# Generics
C# GenericsC# Generics
C# Generics
 
7.data types in c#
7.data types in c#7.data types in c#
7.data types in c#
 
introduction to c #
introduction to c #introduction to c #
introduction to c #
 
.NET Platform. C# Basics
.NET Platform. C# Basics.NET Platform. C# Basics
.NET Platform. C# Basics
 
Unit Testing, TDD and ATDD
Unit Testing, TDD and ATDDUnit Testing, TDD and ATDD
Unit Testing, TDD and ATDD
 
Advanced C#. Part 1
Advanced C#. Part 1Advanced C#. Part 1
Advanced C#. Part 1
 

Recently uploaded

Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 

Recently uploaded (20)

Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 

Abstraction and Encapsulation

  • 2. ABSTRACTION - Ignoring those aspects of an object that are not relevant to the current scope of the problem. - Reduces scope and helps managing complexity.
  • 3. ABSTRACTION - Designing a website to sell new Cars. Car Description Type Price …
  • 4. ABSTRACTION - Do I need to include Service History as a field? No (Because it does not belong to new car and is not relevant to current scope) - Do I need to include Vehicle Registration Number as a field? No (Because currently we do not have and it’s not necessary currently. You get the number after you buy the car.)
  • 5. ABSTRACTION EXCLUDE WHICH IS NOT RELEVANT TO THE CURRENT SCOPE
  • 6. ENCAPSULATION - Provides interface to access the functionality of the object & hides how it is implemented. - Keep the attributes and behavior as one unit – Helps to make it more independent.
  • 7. ENCAPSULATION - Example of Pressing ’A’ on Keyboard. Keyboard Press A --- 65 1000001 Laptop
  • 8. ENCAPSULATION - Keys are exposed as interface and as an end user when I press ‘A’, it is printed on the screen. I do not know how it is implemented. - Implementation is hidden as to how it displays that on screen. - Hiding implementation has a benefit – you can change the implementation later but you can still have the same interface. Maintenance is easy.
  • 9. ENCAPSULATION - Other aspect of attributes and behavior as one unit is it helps to make the object independent. - As a programmer, you know when you press A, 65 (ASCII) is sent as signal but for end user it does not matter. - 65 is hidden from end user and it is private to Keyboard object, only inner methods have access to it. This keeps them as one unit and encapsulated.
  • 10. CONCLUSION - Abstraction comes before Encapsulation - In Abstraction, we are trying to come up with the scope of the problem. - In Encapsulation, we are trying to come up with the approach to solve and implement problem in a better way.