Encapsulation is one of the OOPs concepts in Java which protects the data members of the class. Java is by default encapsulated where we cannot declare a variable outside the class. Java language provides four access specifiers to achieve encapsulation.
Restricting the direct access and providing indirect access through public services called getters and setters methods, is called as encapsulation.
Hiding the internal state and requiring all interaction to be performed through an object's publicly exposed methods is known as Encapsulation.
How to achieve Encapsulation:
By using access modifiers we can achieve.
1. declare class variables as private.
2. define public getters and setters methods to access & update the value of a private variable.
Example code for Encapsulation:
https://github.com/SripriyaPKulkarni/OOPs-Encapsulation
Application of Encapsulation in Framework:
1. All the classes in a framework are an examples of Encapsulation.
2. All the data members declared in POM classes using @FindBy and initializing the data members using Constructor to utilize the data members in methods in test folder.