Introduction of Encapsulation
- Besides inheritance, polymorphism and abstraction, encapsulation is one of fundamental OOP concept.
- mechanism of wrapping up data under single unit
- this is process ehere code and data are wrapped together in single unit
- its like a capsule, which consists of several components in medicines
- Java Bean is fully encapsulated class
- Variables / data of a class can be hidden from other classes and can only be accessed from member function of its own class.
How to encapsulate in Java?
- Make variable of class private (Declare variable as private)
- To modify and view variable values, provide public set and get method.
Benefits of Encapuslation
- Flexibility: Read-only and write only can be made for fields of the class
- The class can control what is stored in its field
- Data Hiding
People are Loving
What is an IP Addressing? Can I Trace Location By Using IP Address
We all mobile phone and computer user need to know that all of us has an unique virtual address attached...
Best 5G Mobile Phones for 2021
Best 5G mobile phones is in the rivalry at this current moment. Well famous populars brands are in this game...
How to transfer data from your old iPhone to new one
Transfer data from your old iphone to new one In iOS world, currently there is best iPhone line up i.e...
Step-wise Instructions to Discover Lost Apple Watch
Sometimes people lost their valuable gadgets in house, office or somewhere concerned. In such situation they may get frustrate and...
Background Processing in Linux. Here is what you need to know!
Introduction of Process Process is an instance of program. A new process is started when you gibe any command to...