SlideShare una empresa de Scribd logo
1 de 1
Descargar para leer sin conexión
Encapsulation in Java is a mechanism to wrap up variables(data) and
methods(code) together as a single unit. It is the process of hiding
information details and protecting data and behavior of the object. It is one
of the four important OOP concepts. The encapsulate class is easy to test,
so it is also better for unit testing.
Advantages of Encapsulation in Java
Encapsulation is binding the data with its related functionalities. Here
functionalities mean “methods” and data means “variables”
So, we keep variable and methods in one place. That place is “class.” Class
is the base for encapsulation.
With Java Encapsulation, you can hide (restrict access) to critical data
members in your code, which improves security
As we discussed earlier, if a data member is declared “private”, then it can
only be accessed within the same class. No outside class can access data
member (variable) of other class.
However, if you need to access these variables, you have to use public
“getter” and “setter” methods.
For more visit our web: - https://hkrtrainings.com/

Más contenido relacionado

Similar a Encapsulation in Java.pdf

FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...
FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...
FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...AnkurSingh340457
 
JAVA-PPT'S.pptx
JAVA-PPT'S.pptxJAVA-PPT'S.pptx
JAVA-PPT'S.pptxRaazIndia
 
JAVA-PPT'S-complete-chrome.pptx
JAVA-PPT'S-complete-chrome.pptxJAVA-PPT'S-complete-chrome.pptx
JAVA-PPT'S-complete-chrome.pptxKunalYadav65140
 
Introduction to OOP concepts
Introduction to OOP conceptsIntroduction to OOP concepts
Introduction to OOP conceptsAhmed Farag
 
Internet and Web Technology (CLASS-15) [JAVA Basics] | NIC/NIELIT Web Technol...
Internet and Web Technology (CLASS-15) [JAVA Basics] | NIC/NIELIT Web Technol...Internet and Web Technology (CLASS-15) [JAVA Basics] | NIC/NIELIT Web Technol...
Internet and Web Technology (CLASS-15) [JAVA Basics] | NIC/NIELIT Web Technol...Ayes Chinmay
 
What is clear to you about OOP in Java- and what concepts are still cl.docx
What is clear to you about OOP in Java- and what concepts are still cl.docxWhat is clear to you about OOP in Java- and what concepts are still cl.docx
What is clear to you about OOP in Java- and what concepts are still cl.docxdorisc7
 
Java Interview Questions For Freshers
Java Interview Questions For FreshersJava Interview Questions For Freshers
Java Interview Questions For Fresherszynofustechnology
 

Similar a Encapsulation in Java.pdf (20)

FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...
FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...
FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...
 
Ashish oot
Ashish ootAshish oot
Ashish oot
 
JAVA-PPT'S.pptx
JAVA-PPT'S.pptxJAVA-PPT'S.pptx
JAVA-PPT'S.pptx
 
JAVA-PPT'S-complete-chrome.pptx
JAVA-PPT'S-complete-chrome.pptxJAVA-PPT'S-complete-chrome.pptx
JAVA-PPT'S-complete-chrome.pptx
 
Introduction to OOP concepts
Introduction to OOP conceptsIntroduction to OOP concepts
Introduction to OOP concepts
 
Oops concepts
Oops conceptsOops concepts
Oops concepts
 
JAVA-PPT'S.pdf
JAVA-PPT'S.pdfJAVA-PPT'S.pdf
JAVA-PPT'S.pdf
 
Oops
OopsOops
Oops
 
Cs8392 oops 5 units notes
Cs8392 oops 5 units notes Cs8392 oops 5 units notes
Cs8392 oops 5 units notes
 
OOP presentation.pptx
OOP presentation.pptxOOP presentation.pptx
OOP presentation.pptx
 
Internet and Web Technology (CLASS-15) [JAVA Basics] | NIC/NIELIT Web Technol...
Internet and Web Technology (CLASS-15) [JAVA Basics] | NIC/NIELIT Web Technol...Internet and Web Technology (CLASS-15) [JAVA Basics] | NIC/NIELIT Web Technol...
Internet and Web Technology (CLASS-15) [JAVA Basics] | NIC/NIELIT Web Technol...
 
What is clear to you about OOP in Java- and what concepts are still cl.docx
What is clear to you about OOP in Java- and what concepts are still cl.docxWhat is clear to you about OOP in Java- and what concepts are still cl.docx
What is clear to you about OOP in Java- and what concepts are still cl.docx
 
Encapsulation
EncapsulationEncapsulation
Encapsulation
 
Java Interview Questions For Freshers
Java Interview Questions For FreshersJava Interview Questions For Freshers
Java Interview Questions For Freshers
 
Suga java training_with_footer
Suga java training_with_footerSuga java training_with_footer
Suga java training_with_footer
 
Java_Interview Qns
Java_Interview QnsJava_Interview Qns
Java_Interview Qns
 
OOP_presentation.pptx
OOP_presentation.pptxOOP_presentation.pptx
OOP_presentation.pptx
 
javaopps concepts
javaopps conceptsjavaopps concepts
javaopps concepts
 
Chapter 8 java
Chapter 8 javaChapter 8 java
Chapter 8 java
 
python.pptx
python.pptxpython.pptx
python.pptx
 

Último

Here are five tips to make house packing quicker and faster.pptx
Here are five tips to make house packing quicker and faster.pptxHere are five tips to make house packing quicker and faster.pptx
Here are five tips to make house packing quicker and faster.pptxnidhimovee
 
7 Ways To Select Best Corporate Gifts | Corporate Gifts Supplier
7 Ways To Select Best Corporate Gifts | Corporate Gifts Supplier7 Ways To Select Best Corporate Gifts | Corporate Gifts Supplier
7 Ways To Select Best Corporate Gifts | Corporate Gifts SupplierVerve Corporate Gifts
 
What To Look For in Employee Onboarding Software?
What To Look For in Employee Onboarding Software?What To Look For in Employee Onboarding Software?
What To Look For in Employee Onboarding Software?eZaango HR
 
THIRTEEN ODDS DESIGN DOCKYARD PRIVATE LIMITED
THIRTEEN ODDS DESIGN DOCKYARD PRIVATE LIMITEDTHIRTEEN ODDS DESIGN DOCKYARD PRIVATE LIMITED
THIRTEEN ODDS DESIGN DOCKYARD PRIVATE LIMITEDAMRITMISHRA46
 
one of the best by art prints online here
one of the best by art prints online hereone of the best by art prints online here
one of the best by art prints online heretoyism501
 
Custom Speech Writing Services Online | Writing Sharks
Custom Speech Writing Services Online | Writing SharksCustom Speech Writing Services Online | Writing Sharks
Custom Speech Writing Services Online | Writing SharksWritingSharks
 
Touchstone Lofts – Loft conversions specialist
Touchstone Lofts – Loft conversions specialistTouchstone Lofts – Loft conversions specialist
Touchstone Lofts – Loft conversions specialistTouchstone Lofts
 
From A To Z Understanding The Full Spectrum Of Employment Background Checks
From A To Z Understanding The Full Spectrum Of Employment Background ChecksFrom A To Z Understanding The Full Spectrum Of Employment Background Checks
From A To Z Understanding The Full Spectrum Of Employment Background Checksaffordablebackgroundchecks
 
How Can Dumpster Rental Streamline Yard Waste Management In San Fernando Valley
How Can Dumpster Rental Streamline Yard Waste Management In San Fernando ValleyHow Can Dumpster Rental Streamline Yard Waste Management In San Fernando Valley
How Can Dumpster Rental Streamline Yard Waste Management In San Fernando ValleyBG’s Big Box Service
 
interior design company dubai | Sites DXB
interior design company dubai | Sites DXBinterior design company dubai | Sites DXB
interior design company dubai | Sites DXBSitesDXB
 
ONEUNIVERSE_PORTFOLIO_ENGLISH_202403.pdf
ONEUNIVERSE_PORTFOLIO_ENGLISH_202403.pdfONEUNIVERSE_PORTFOLIO_ENGLISH_202403.pdf
ONEUNIVERSE_PORTFOLIO_ENGLISH_202403.pdfLeonaNguyenThuyLinh
 
How Do Cleaners Prepare Before Commencing Builders Cleaning?
How Do Cleaners Prepare Before Commencing Builders Cleaning?How Do Cleaners Prepare Before Commencing Builders Cleaning?
How Do Cleaners Prepare Before Commencing Builders Cleaning?Renovation Cleaning
 
The Power of Quick Commerce Data Monitoring A Comprehensive Guide.pdf
The Power of Quick Commerce Data Monitoring A Comprehensive Guide.pdfThe Power of Quick Commerce Data Monitoring A Comprehensive Guide.pdf
The Power of Quick Commerce Data Monitoring A Comprehensive Guide.pdfjacklutz2
 
International Sustainable and Efficient Irrigation Solutions
International Sustainable and Efficient Irrigation SolutionsInternational Sustainable and Efficient Irrigation Solutions
International Sustainable and Efficient Irrigation SolutionsIrri Design Studio
 
Retirement Planning - Transferring UK Pension to France.pptx
Retirement Planning - Transferring UK Pension to France.pptxRetirement Planning - Transferring UK Pension to France.pptx
Retirement Planning - Transferring UK Pension to France.pptxChaseBuchanan
 
The Expertise of Our Web Development Company
The Expertise of Our Web Development CompanyThe Expertise of Our Web Development Company
The Expertise of Our Web Development CompanyNetqom Solutions
 
Point of View Glazing - Expert Glazing Services
Point of View Glazing - Expert Glazing ServicesPoint of View Glazing - Expert Glazing Services
Point of View Glazing - Expert Glazing ServicesPoint of View Glazing
 

Último (19)

Here are five tips to make house packing quicker and faster.pptx
Here are five tips to make house packing quicker and faster.pptxHere are five tips to make house packing quicker and faster.pptx
Here are five tips to make house packing quicker and faster.pptx
 
7 Ways To Select Best Corporate Gifts | Corporate Gifts Supplier
7 Ways To Select Best Corporate Gifts | Corporate Gifts Supplier7 Ways To Select Best Corporate Gifts | Corporate Gifts Supplier
7 Ways To Select Best Corporate Gifts | Corporate Gifts Supplier
 
What To Look For in Employee Onboarding Software?
What To Look For in Employee Onboarding Software?What To Look For in Employee Onboarding Software?
What To Look For in Employee Onboarding Software?
 
THIRTEEN ODDS DESIGN DOCKYARD PRIVATE LIMITED
THIRTEEN ODDS DESIGN DOCKYARD PRIVATE LIMITEDTHIRTEEN ODDS DESIGN DOCKYARD PRIVATE LIMITED
THIRTEEN ODDS DESIGN DOCKYARD PRIVATE LIMITED
 
one of the best by art prints online here
one of the best by art prints online hereone of the best by art prints online here
one of the best by art prints online here
 
Custom Speech Writing Services Online | Writing Sharks
Custom Speech Writing Services Online | Writing SharksCustom Speech Writing Services Online | Writing Sharks
Custom Speech Writing Services Online | Writing Sharks
 
Touchstone Lofts – Loft conversions specialist
Touchstone Lofts – Loft conversions specialistTouchstone Lofts – Loft conversions specialist
Touchstone Lofts – Loft conversions specialist
 
From A To Z Understanding The Full Spectrum Of Employment Background Checks
From A To Z Understanding The Full Spectrum Of Employment Background ChecksFrom A To Z Understanding The Full Spectrum Of Employment Background Checks
From A To Z Understanding The Full Spectrum Of Employment Background Checks
 
How Can Dumpster Rental Streamline Yard Waste Management In San Fernando Valley
How Can Dumpster Rental Streamline Yard Waste Management In San Fernando ValleyHow Can Dumpster Rental Streamline Yard Waste Management In San Fernando Valley
How Can Dumpster Rental Streamline Yard Waste Management In San Fernando Valley
 
interior design company dubai | Sites DXB
interior design company dubai | Sites DXBinterior design company dubai | Sites DXB
interior design company dubai | Sites DXB
 
ONEUNIVERSE_PORTFOLIO_ENGLISH_202403.pdf
ONEUNIVERSE_PORTFOLIO_ENGLISH_202403.pdfONEUNIVERSE_PORTFOLIO_ENGLISH_202403.pdf
ONEUNIVERSE_PORTFOLIO_ENGLISH_202403.pdf
 
A Guide to AI-powered Lead Generation Strategies
A Guide to AI-powered Lead Generation StrategiesA Guide to AI-powered Lead Generation Strategies
A Guide to AI-powered Lead Generation Strategies
 
How Do Cleaners Prepare Before Commencing Builders Cleaning?
How Do Cleaners Prepare Before Commencing Builders Cleaning?How Do Cleaners Prepare Before Commencing Builders Cleaning?
How Do Cleaners Prepare Before Commencing Builders Cleaning?
 
The Power of Quick Commerce Data Monitoring A Comprehensive Guide.pdf
The Power of Quick Commerce Data Monitoring A Comprehensive Guide.pdfThe Power of Quick Commerce Data Monitoring A Comprehensive Guide.pdf
The Power of Quick Commerce Data Monitoring A Comprehensive Guide.pdf
 
International Sustainable and Efficient Irrigation Solutions
International Sustainable and Efficient Irrigation SolutionsInternational Sustainable and Efficient Irrigation Solutions
International Sustainable and Efficient Irrigation Solutions
 
QuickBooks Multi User Mode Not Working Solutions Steps.pdf
QuickBooks Multi User Mode Not Working Solutions Steps.pdfQuickBooks Multi User Mode Not Working Solutions Steps.pdf
QuickBooks Multi User Mode Not Working Solutions Steps.pdf
 
Retirement Planning - Transferring UK Pension to France.pptx
Retirement Planning - Transferring UK Pension to France.pptxRetirement Planning - Transferring UK Pension to France.pptx
Retirement Planning - Transferring UK Pension to France.pptx
 
The Expertise of Our Web Development Company
The Expertise of Our Web Development CompanyThe Expertise of Our Web Development Company
The Expertise of Our Web Development Company
 
Point of View Glazing - Expert Glazing Services
Point of View Glazing - Expert Glazing ServicesPoint of View Glazing - Expert Glazing Services
Point of View Glazing - Expert Glazing Services
 

Encapsulation in Java.pdf

  • 1. Encapsulation in Java is a mechanism to wrap up variables(data) and methods(code) together as a single unit. It is the process of hiding information details and protecting data and behavior of the object. It is one of the four important OOP concepts. The encapsulate class is easy to test, so it is also better for unit testing. Advantages of Encapsulation in Java Encapsulation is binding the data with its related functionalities. Here functionalities mean “methods” and data means “variables” So, we keep variable and methods in one place. That place is “class.” Class is the base for encapsulation. With Java Encapsulation, you can hide (restrict access) to critical data members in your code, which improves security As we discussed earlier, if a data member is declared “private”, then it can only be accessed within the same class. No outside class can access data member (variable) of other class. However, if you need to access these variables, you have to use public “getter” and “setter” methods. For more visit our web: - https://hkrtrainings.com/