Does It Accomplish Data Hiding?

What is a class and how does it accomplish data hiding? ... Methods and variables declared private can not be access outside of the class. Those can be only accessed internally, it means that they are hidden from the outside.

How do you achieve data hiding?

Data hiding is achieved by using the private access specifier.
  1. Example: We can understand data hiding with an example. ...
  2. Private members/methods: Functions and variables declared as private can be accessed only within the same class, and they cannot be accessed outside the class they are declared.

How is data hiding achieved in OOP?

So data hiding is achieved by making the members of the class private. Access to private members is restricted and is only available to the member functions of the same class. However the public part of the object is accessible outside the class.

Maya Lin-Takahashi

Maya Lin-Takahashi

Consumer Tech & Gadget Reviewer

Maya is a hardware enthusiast who tests and reviews smart home devices, smartphones, wearables, and audio gear. She focuses on practical consumer value and build quality.