SlideShare a Scribd company logo
2SC2 – OOP C# Dudy Fathan Ali S.Kom
Abstraction dan Encapsulation
2SC2
Dudy Fathan Ali, S.Kom (DFA)
2015
CEP - CCIT
Fakultas Teknik Universitas Indonesia
Abstraction
2SC2 – OOP C# Dudy Fathan Ali S.Kom
You are the salesman, please help the customer..
Hey, I need a
Car.
Abstraction
2SC2 – OOP C# Dudy Fathan Ali S.Kom
Hey, I need a
Car.
You are the salesman, please help the customer..
Abstraction
2SC2 – OOP C# Dudy Fathan Ali S.Kom
Abstraction involves extracting only the relevant
information.
Courseware NIIT – Object Oriented Programming Using C# - 1
Abstraction
2SC2 – OOP C# Dudy Fathan Ali S.Kom
In a programmer’s perspective..
Display
Car
Insert
Car
Class
Car
I want to
Display the Car
Delete
Car
Just because the user want to display it, doesn’t
mean insert and delete function is unavailable.
Encapsulation
2SC2 – OOP C# Dudy Fathan Ali S.Kom
Encapsulation, in the context of C#, refers to an object's ability to hide
data and behavior that are not necessary to its user.
www.techopedia.com
Private -
Employee’s
Salary
I want to
access ID
Employee
Yes, because
it’s Public
Public –
Name, ID of
Employee
Cashier
Human Resources
Database
Human Resources
Database
Encapsulation
2SC2 – OOP C# Dudy Fathan Ali S.Kom
Encapsulation, in the context of C#, refers to an object's ability to hide
data and behavior that are not necessary to its user.
www.techopedia.com
Private -
Employee’s
Salary
Public –
Name, ID of
Employee
I want to
access my
friend’s salary
No, because it’s
private!! It
doesn’t
belongs to
cashier.
Cashier
Human Resources
Database
Encapsulation
2SC2 – OOP C# Dudy Fathan Ali S.Kom
Encapsulation, in the context of C#, refers to an object's ability to hide
data and behavior that are not necessary to its user.
www.techopedia.com
Private -
Employee’s
Salary
Public –
Name, ID of
EmployeeHRD Manager
I want to
access my
friend’s salary
Yes, because this
data is belongs to
him
Yes, because this
data is belongs to
him and also it’s
public
Encapsulation
2SC2 – OOP C# Dudy Fathan Ali S.Kom
In a programmer’s perspective..
Private –
Employee’s
Salary
Public –
Name, ID of
Employee
Access to all code in
the program
Class HR_Data
Access to only
members of the
same class
Yes, same
class!
method
method
Private
Encapsulation – Access Specifier
2SC2 – OOP C# Dudy Fathan Ali S.Kom
Encapsulation, in the context of C#, refers to an object's ability to hide
data and behavior that are not necessary to its user.
www.techopedia.com
Public Protected
Internal
Protected
Internal
Access
Specifier
Encapsulation – Access Specifier
2SC2 – OOP C# Dudy Fathan Ali S.Kom
Encapsulation, in the context of C#, refers to an object's ability to hide
data and behavior that are not necessary to its user.
www.techopedia.com
Encapsulation – Access Specifier
2SC2 – OOP C# Dudy Fathan Ali S.Kom
Encapsulation, in the context of C#, refers to an object's ability to hide
data and behavior that are not necessary to its user.
www.techopedia.com
Class DisplayData
{
public void Method1()
{
Console.WriteLine(“Public”);
Method2();
}
private void Method2()
{
Console.WriteLine(“Private”);
}
}
Output :
Class Program :
DisplayData dd = new
DisplayData();
dd.Method1();
Public
Private
Access Specifier
Encapsulation – Access Specifier
2SC2 – OOP C# Dudy Fathan Ali S.Kom
Encapsulation, in the context of C#, refers to an object's ability to hide
data and behavior that are not necessary to its user.
www.techopedia.com
Class DisplayData
{
public void Method1()
{
Console.WriteLine(“Public”);
Method2();
}
private void Method2()
{
Console.WriteLine(“Private”);
}
}
Output :
Error!! Because method2()
has a private access.
Class Program :
DisplayData dd = new
DisplayData();
dd.Method2();
Access Specifier
3SC4 PNJ – Q5 Dudy Fathan Ali S.Kom
Terima Kasih
Dudy Fathan Ali S.Kom
dudy.fathan@eng.ui.ac.id

More Related Content

Viewers also liked (10)

PPTX
pointers,virtual functions and polymorphism
rattaj
 
PPTX
9 subprograms
Munawar Ahmed
 
PDF
08 subprograms
baran19901990
 
PPT
Java multi threading
Raja Sekhar
 
PPTX
Threads in JAVA
Haldia Institute of Technology
 
PPT
Presentation on generation of languages
Richa Pant
 
PPTX
Unit1 principle of programming language
Vasavi College of Engg
 
PPTX
Pointers, virtual function and polymorphism
lalithambiga kamaraj
 
PPTX
07. Virtual Functions
Haresh Jaiswal
 
PPT
Unit 3 principles of programming language
Vasavi College of Engg
 
pointers,virtual functions and polymorphism
rattaj
 
9 subprograms
Munawar Ahmed
 
08 subprograms
baran19901990
 
Java multi threading
Raja Sekhar
 
Presentation on generation of languages
Richa Pant
 
Unit1 principle of programming language
Vasavi College of Engg
 
Pointers, virtual function and polymorphism
lalithambiga kamaraj
 
07. Virtual Functions
Haresh Jaiswal
 
Unit 3 principles of programming language
Vasavi College of Engg
 

Similar to Object Oriented Programming - Abstraction & Encapsulation (20)

PPTX
Programming Primer Encapsulation CS
sunmitraeducation
 
PPTX
Programming Primer EncapsulationVB
sunmitraeducation
 
PPTX
Module 4 Effect of Reuse on using Encapsulation.pptx
ramlingams
 
PDF
Lecture09a computer applicationsie1_dratifshahzad
Atif Shahzad
 
PPTX
[OOP - Lec 08] Encapsulation (Information Hiding)
Muhammad Hammad Waseem
 
PPTX
Prese00yq3whesfthewgdsyuvferwyjhjdfegcyjgfz.pptx
RajshreePathir
 
PPTX
Presentation related to Encapsulation and OOPs
vinitsinghthakur46
 
DOCX
Benefits of encapsulation
Muhammad Nawzir Khan
 
PPTX
Presen5416846534653416354165341864adeadvdes
RajshreePathir
 
PPTX
Prese00z213hfcyudegtyfwyyudeqw7tgfi7u.pptx
RajshreePathir
 
PPTX
oop ppt.pptxfwefwefweqwedrqwerwerweewrewe
moeezrana329
 
PPTX
27csharp
Sireesh K
 
PPTX
27c
Sireesh K
 
PPTX
Encapsulation C++ Piller of OOP it is the important piller
an7539661
 
PPTX
Presentation - Copy no vaperpoit asd.pptx
RajshreePathir
 
PPTX
Encapsulation
Burhan Ahmed
 
PDF
Chapter2 Encapsulation (Java)
Dyah Fajar Nur Rohmah
 
PPS
Aae oop xp_03
Niit Care
 
PPTX
Access Modifiers in C# ,Inheritance and Encapsulation
Abid Kohistani
 
PPTX
Encapsulation
Ducat India
 
Programming Primer Encapsulation CS
sunmitraeducation
 
Programming Primer EncapsulationVB
sunmitraeducation
 
Module 4 Effect of Reuse on using Encapsulation.pptx
ramlingams
 
Lecture09a computer applicationsie1_dratifshahzad
Atif Shahzad
 
[OOP - Lec 08] Encapsulation (Information Hiding)
Muhammad Hammad Waseem
 
Prese00yq3whesfthewgdsyuvferwyjhjdfegcyjgfz.pptx
RajshreePathir
 
Presentation related to Encapsulation and OOPs
vinitsinghthakur46
 
Benefits of encapsulation
Muhammad Nawzir Khan
 
Presen5416846534653416354165341864adeadvdes
RajshreePathir
 
Prese00z213hfcyudegtyfwyyudeqw7tgfi7u.pptx
RajshreePathir
 
oop ppt.pptxfwefwefweqwedrqwerwerweewrewe
moeezrana329
 
27csharp
Sireesh K
 
Encapsulation C++ Piller of OOP it is the important piller
an7539661
 
Presentation - Copy no vaperpoit asd.pptx
RajshreePathir
 
Encapsulation
Burhan Ahmed
 
Chapter2 Encapsulation (Java)
Dyah Fajar Nur Rohmah
 
Aae oop xp_03
Niit Care
 
Access Modifiers in C# ,Inheritance and Encapsulation
Abid Kohistani
 
Encapsulation
Ducat India
 
Ad

More from Dudy Ali (20)

PDF
Understanding COM+
Dudy Ali
 
PDF
Distributed Application Development (Introduction)
Dudy Ali
 
PPTX
Java CRUD Mechanism with SQL Server Database
Dudy Ali
 
PPTX
Network Socket Programming with JAVA
Dudy Ali
 
PPTX
Review Materi ASP.NET
Dudy Ali
 
PPTX
XML Schema Part 2
Dudy Ali
 
PPTX
XML Schema Part 1
Dudy Ali
 
PPTX
Rendering XML Document
Dudy Ali
 
PPTX
Pengantar XML
Dudy Ali
 
PPTX
Pengantar XML DOM
Dudy Ali
 
PPTX
Pengantar ADO.NET
Dudy Ali
 
PPTX
Database Connectivity with JDBC
Dudy Ali
 
PPTX
XML - Displaying Data ith XSLT
Dudy Ali
 
PPTX
Algorithm & Data Structure - Algoritma Pengurutan
Dudy Ali
 
PPTX
Algorithm & Data Structure - Pengantar
Dudy Ali
 
PPTX
Object Oriented Programming - Value Types & Reference Types
Dudy Ali
 
PPTX
Object Oriented Programming - Inheritance
Dudy Ali
 
PPTX
Object Oriented Programming - File Input & Output
Dudy Ali
 
PPTX
Object Oriented Programming - Constructors & Destructors
Dudy Ali
 
PPTX
Web Programming Syaria - Pengenalan Halaman Web
Dudy Ali
 
Understanding COM+
Dudy Ali
 
Distributed Application Development (Introduction)
Dudy Ali
 
Java CRUD Mechanism with SQL Server Database
Dudy Ali
 
Network Socket Programming with JAVA
Dudy Ali
 
Review Materi ASP.NET
Dudy Ali
 
XML Schema Part 2
Dudy Ali
 
XML Schema Part 1
Dudy Ali
 
Rendering XML Document
Dudy Ali
 
Pengantar XML
Dudy Ali
 
Pengantar XML DOM
Dudy Ali
 
Pengantar ADO.NET
Dudy Ali
 
Database Connectivity with JDBC
Dudy Ali
 
XML - Displaying Data ith XSLT
Dudy Ali
 
Algorithm & Data Structure - Algoritma Pengurutan
Dudy Ali
 
Algorithm & Data Structure - Pengantar
Dudy Ali
 
Object Oriented Programming - Value Types & Reference Types
Dudy Ali
 
Object Oriented Programming - Inheritance
Dudy Ali
 
Object Oriented Programming - File Input & Output
Dudy Ali
 
Object Oriented Programming - Constructors & Destructors
Dudy Ali
 
Web Programming Syaria - Pengenalan Halaman Web
Dudy Ali
 
Ad

Recently uploaded (20)

PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PDF
July Patch Tuesday
Ivanti
 
PDF
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PDF
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
July Patch Tuesday
Ivanti
 
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 

Object Oriented Programming - Abstraction & Encapsulation

  • 1. 2SC2 – OOP C# Dudy Fathan Ali S.Kom Abstraction dan Encapsulation 2SC2 Dudy Fathan Ali, S.Kom (DFA) 2015 CEP - CCIT Fakultas Teknik Universitas Indonesia
  • 2. Abstraction 2SC2 – OOP C# Dudy Fathan Ali S.Kom You are the salesman, please help the customer.. Hey, I need a Car.
  • 3. Abstraction 2SC2 – OOP C# Dudy Fathan Ali S.Kom Hey, I need a Car. You are the salesman, please help the customer..
  • 4. Abstraction 2SC2 – OOP C# Dudy Fathan Ali S.Kom Abstraction involves extracting only the relevant information. Courseware NIIT – Object Oriented Programming Using C# - 1
  • 5. Abstraction 2SC2 – OOP C# Dudy Fathan Ali S.Kom In a programmer’s perspective.. Display Car Insert Car Class Car I want to Display the Car Delete Car Just because the user want to display it, doesn’t mean insert and delete function is unavailable.
  • 6. Encapsulation 2SC2 – OOP C# Dudy Fathan Ali S.Kom Encapsulation, in the context of C#, refers to an object's ability to hide data and behavior that are not necessary to its user. www.techopedia.com Private - Employee’s Salary I want to access ID Employee Yes, because it’s Public Public – Name, ID of Employee Cashier Human Resources Database
  • 7. Human Resources Database Encapsulation 2SC2 – OOP C# Dudy Fathan Ali S.Kom Encapsulation, in the context of C#, refers to an object's ability to hide data and behavior that are not necessary to its user. www.techopedia.com Private - Employee’s Salary Public – Name, ID of Employee I want to access my friend’s salary No, because it’s private!! It doesn’t belongs to cashier. Cashier
  • 8. Human Resources Database Encapsulation 2SC2 – OOP C# Dudy Fathan Ali S.Kom Encapsulation, in the context of C#, refers to an object's ability to hide data and behavior that are not necessary to its user. www.techopedia.com Private - Employee’s Salary Public – Name, ID of EmployeeHRD Manager I want to access my friend’s salary Yes, because this data is belongs to him Yes, because this data is belongs to him and also it’s public
  • 9. Encapsulation 2SC2 – OOP C# Dudy Fathan Ali S.Kom In a programmer’s perspective.. Private – Employee’s Salary Public – Name, ID of Employee Access to all code in the program Class HR_Data Access to only members of the same class Yes, same class! method method
  • 10. Private Encapsulation – Access Specifier 2SC2 – OOP C# Dudy Fathan Ali S.Kom Encapsulation, in the context of C#, refers to an object's ability to hide data and behavior that are not necessary to its user. www.techopedia.com Public Protected Internal Protected Internal Access Specifier
  • 11. Encapsulation – Access Specifier 2SC2 – OOP C# Dudy Fathan Ali S.Kom Encapsulation, in the context of C#, refers to an object's ability to hide data and behavior that are not necessary to its user. www.techopedia.com
  • 12. Encapsulation – Access Specifier 2SC2 – OOP C# Dudy Fathan Ali S.Kom Encapsulation, in the context of C#, refers to an object's ability to hide data and behavior that are not necessary to its user. www.techopedia.com Class DisplayData { public void Method1() { Console.WriteLine(“Public”); Method2(); } private void Method2() { Console.WriteLine(“Private”); } } Output : Class Program : DisplayData dd = new DisplayData(); dd.Method1(); Public Private Access Specifier
  • 13. Encapsulation – Access Specifier 2SC2 – OOP C# Dudy Fathan Ali S.Kom Encapsulation, in the context of C#, refers to an object's ability to hide data and behavior that are not necessary to its user. www.techopedia.com Class DisplayData { public void Method1() { Console.WriteLine(“Public”); Method2(); } private void Method2() { Console.WriteLine(“Private”); } } Output : Error!! Because method2() has a private access. Class Program : DisplayData dd = new DisplayData(); dd.Method2(); Access Specifier
  • 14. 3SC4 PNJ – Q5 Dudy Fathan Ali S.Kom Terima Kasih Dudy Fathan Ali S.Kom [email protected]