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.
Your words touch the heart. You write beautifully and have good expressing
ReplyDeleteclick for more
So for I used to comment anywhere /any blogs or videos now I do commenting ,,really it matter ,,thanks lot ,explaining in details,,,
ReplyDeleteright here
6. Well hello there! it was so fantastic to visit your blog and to read article. And I have
ReplyDeletea question for you. Have you ever done article blogging
Read this post here
Thank you very much for writing such an interesting article on this topic. This has really made me think and I hope to read more. software development company
ReplyDeleteThank you for taking the time to write such an informative post. Your blog is not only informative, but it is also very creative.
ReplyDeleteweb application development company