Skip to main content

Command Palette

Search for a command to run...

What do you mean by data encapsulation

Published
1 min read
S

I love learning about technology and sharing that with others

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

More from this blog

H

hashcodehub

271 posts

Consistent, Passionate and Organized :)