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
Ad

Recommended

C++ c#
C++ c#
Sireesh K
 
Keyword Presentation
Keyword Presentation
Satyamevjayte Haxor
 
3 linear regression deep
3 linear regression deep
Tarlan Ahadli
 
SOLID principles
SOLID principles
Dmitry Kandalov
 
Innoveo coding dojo
Innoveo coding dojo
Tech Head Brothers
 
SUNIL_KAMBOJ-PHE-CAD
SUNIL_KAMBOJ-PHE-CAD
Sunil Kamboj
 
hardeep new resume CURRENT
hardeep new resume CURRENT
Hardeep Bharaj
 
Muhamme K A_Resume
Muhamme K A_Resume
MUHAMMED KOTALAVALAPPIL ALI
 
pointers,virtual functions and polymorphism
pointers,virtual functions and polymorphism
rattaj
 
9 subprograms
9 subprograms
Munawar Ahmed
 
08 subprograms
08 subprograms
baran19901990
 
Java multi threading
Java multi threading
Raja Sekhar
 
Threads in JAVA
Threads in JAVA
Haldia Institute of Technology
 
Presentation on generation of languages
Presentation on generation of languages
Richa Pant
 
Unit1 principle of programming language
Unit1 principle of programming language
Vasavi College of Engg
 
Pointers, virtual function and polymorphism
Pointers, virtual function and polymorphism
lalithambiga kamaraj
 
07. Virtual Functions
07. Virtual Functions
Haresh Jaiswal
 
Unit 3 principles of programming language
Unit 3 principles of programming language
Vasavi College of Engg
 
Programming Primer Encapsulation CS
Programming Primer Encapsulation CS
sunmitraeducation
 
Programming Primer EncapsulationVB
Programming Primer EncapsulationVB
sunmitraeducation
 
Module 4 Effect of Reuse on using Encapsulation.pptx
Module 4 Effect of Reuse on using Encapsulation.pptx
ramlingams
 
Lecture09a computer applicationsie1_dratifshahzad
Lecture09a computer applicationsie1_dratifshahzad
Atif Shahzad
 
[OOP - Lec 08] Encapsulation (Information Hiding)
[OOP - Lec 08] Encapsulation (Information Hiding)
Muhammad Hammad Waseem
 
Prese00yq3whesfthewgdsyuvferwyjhjdfegcyjgfz.pptx
Prese00yq3whesfthewgdsyuvferwyjhjdfegcyjgfz.pptx
RajshreePathir
 
Presentation related to Encapsulation and OOPs
Presentation related to Encapsulation and OOPs
vinitsinghthakur46
 
Benefits of encapsulation
Benefits of encapsulation
Muhammad Nawzir Khan
 
Presen5416846534653416354165341864adeadvdes
Presen5416846534653416354165341864adeadvdes
RajshreePathir
 
Prese00z213hfcyudegtyfwyyudeqw7tgfi7u.pptx
Prese00z213hfcyudegtyfwyyudeqw7tgfi7u.pptx
RajshreePathir
 
oop ppt.pptxfwefwefweqwedrqwerwerweewrewe
oop ppt.pptxfwefwefweqwedrqwerwerweewrewe
moeezrana329
 
27csharp
27csharp
Sireesh K
 

More Related Content

Viewers also liked (10)

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

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

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

More from Dudy Ali (20)

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

Recently uploaded (20)

Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Puppy jhon
 
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
AmirStern2
 
FME for Good: Integrating Multiple Data Sources with APIs to Support Local Ch...
FME for Good: Integrating Multiple Data Sources with APIs to Support Local Ch...
Safe Software
 
The State of Web3 Industry- Industry Report
The State of Web3 Industry- Industry Report
Liveplex
 
Data Validation and System Interoperability
Data Validation and System Interoperability
Safe Software
 
Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...
BookNet Canada
 
Artificial Intelligence in the Nonprofit Boardroom.pdf
Artificial Intelligence in the Nonprofit Boardroom.pdf
OnBoard
 
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
NTT DATA Technology & Innovation
 
Crypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdf
Stephen Perrenod
 
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Shashikant Jagtap
 
AudGram Review: Build Visually Appealing, AI-Enhanced Audiograms to Engage Yo...
AudGram Review: Build Visually Appealing, AI-Enhanced Audiograms to Engage Yo...
SOFTTECHHUB
 
Murdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementary
JorgeSemperteguiMont
 
Enabling BIM / GIS integrations with Other Systems with FME
Enabling BIM / GIS integrations with Other Systems with FME
Safe Software
 
MuleSoft for AgentForce : Topic Center and API Catalog
MuleSoft for AgentForce : Topic Center and API Catalog
shyamraj55
 
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Anish Kumar
 
Oracle Cloud and AI Specialization Program
Oracle Cloud and AI Specialization Program
VICTOR MAESTRE RAMIREZ
 
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Alliance
 
Reducing Conflicts and Increasing Safety Along the Cycling Networks of East-F...
Reducing Conflicts and Increasing Safety Along the Cycling Networks of East-F...
Safe Software
 
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
biswajitbanerjee38
 
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Alliance
 
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Puppy jhon
 
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
AmirStern2
 
FME for Good: Integrating Multiple Data Sources with APIs to Support Local Ch...
FME for Good: Integrating Multiple Data Sources with APIs to Support Local Ch...
Safe Software
 
The State of Web3 Industry- Industry Report
The State of Web3 Industry- Industry Report
Liveplex
 
Data Validation and System Interoperability
Data Validation and System Interoperability
Safe Software
 
Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...
BookNet Canada
 
Artificial Intelligence in the Nonprofit Boardroom.pdf
Artificial Intelligence in the Nonprofit Boardroom.pdf
OnBoard
 
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
NTT DATA Technology & Innovation
 
Crypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdf
Stephen Perrenod
 
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Shashikant Jagtap
 
AudGram Review: Build Visually Appealing, AI-Enhanced Audiograms to Engage Yo...
AudGram Review: Build Visually Appealing, AI-Enhanced Audiograms to Engage Yo...
SOFTTECHHUB
 
Murdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementary
JorgeSemperteguiMont
 
Enabling BIM / GIS integrations with Other Systems with FME
Enabling BIM / GIS integrations with Other Systems with FME
Safe Software
 
MuleSoft for AgentForce : Topic Center and API Catalog
MuleSoft for AgentForce : Topic Center and API Catalog
shyamraj55
 
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Anish Kumar
 
Oracle Cloud and AI Specialization Program
Oracle Cloud and AI Specialization Program
VICTOR MAESTRE RAMIREZ
 
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Alliance
 
Reducing Conflicts and Increasing Safety Along the Cycling Networks of East-F...
Reducing Conflicts and Increasing Safety Along the Cycling Networks of East-F...
Safe Software
 
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
biswajitbanerjee38
 
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Alliance
 

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]