Encapsulation is the concept of bundling data and methods together and restricting access to certain parts of an object.
class Car {
private String model;
private int year;
// Getter and Setter methods
public String getModel() {
return model;
}
public void setModel(String model) {
this.model = model;
}
public int getYear() {
return year;
}
public void setYear(int year) {
this.year = year;
}
}