Java for beginners - Chapter 25 : Getter and setter methods in Java

preview_player
Показать описание
Getter and setter methods in Java :
Encapsulation in java.
How to achieve encapsulation ?
Benefits of encapsulation

Encapsulation is one of the four fundamental OOP concepts.
It is a mechanism of wrapping the variables and methods together as a single unit.
Data Hiding : Through encapsulation the variables of a class will be hidden from other classes and they can be accessed through the methods of their current class.

Benefits of Encapsulation :
Fields of a class can be made read-only or write-only.
A class will have complete control over what is stored in its fields.

To achieve encapsulation :
Declare the variables of class as private.
Using public setter and getter methods to modify and view the variable values.

ankpro
ankpro training
C#
C sharp
Bangalore
Rajajinagar
Selenium
Coded UI
Mobile automation testing
Mobile testing
JQuery
JavaScript
.Net
C
C++
Components of the .Net framework
Hello World
Literal
Keywords
Variable
Data types
Operators
Branching
Loops
Arrays
Strings
Structures
Enums
Functions
Рекомендации по теме