What do you mean by data encapsulation

What do you mean by data encapsulation

  1. Data encapsulation is the concept of hiding data attributes(instance variable) and behavior(methods) into a single unit (object).

  2. We can implement encapsulation by making the instance variable as private and getters and setters as public so that we can maintain our state consistenly

  3. Outside classes will not be aware of the implentation outside class will only access the getters and setters method by an object

  4. Flexbility : we can make the variables only read only or write only with encapsulation -> for only read only we will not make the setter method