Computer Applications

In what way does a class enforce data hiding?

Encapsulation & Inheritance in Java

31 Likes

Answer

A class enforces data hiding through access specifiers. Java provides three access specifiers for its class members — public, private and protected. The private members of a class are only accessible within the class. They are hidden to the code outside the class. The protected members are accessible from classes within the same package and subclasses.

Answered By

20 Likes


Related Questions