a OOPS Concept: Encapsulation(Classes with the method, variables & logics)
What is Encapsulation?
Encapsulation bundles an object's data (fields) and the methods that operate on that data together within a single class, typically keeping fields private and exposing controlled access via public getter/setter methods.
public class User {
private String email;
public String getEmail() { return email; }
public void setEmail(String email) {
if (email.contains("@")) this.email = email;
}
}
Why It Matters
Encapsulation keeps validation logic in one place (like the setter above), preventing invalid data from ever being assigned directly to the field.
Ready to master real-world software testing?
Learn manual and automation testing hands-on with mentor-led sessions.
.png)