Ask Question
10 September, 20:57

Data hiding, which means that critical data stored inside the object is protected from code outside the object, is accomplished in Java by: A. using the public access specifier on the class methods B. using the private access specifier on the class methods C. using the private access specifier on the class definition D. using the private access specifier on the class fields

+5
Answers (1)
  1. 10 September, 21:40
    0
    Option (D) using the private access specifier on the class fields

    Explanation:

    The private access modifier can be used to hide the data. Methods and data variables (fields) can be declared with the private access modifier. Data hiding is a OOPS Concept which can be achieved with the private keyword (private access modifier). The access modifiers are of types Public, Private, Protected and Default (no access modifier - no need to explicitly specify the default keyword). Data hiding means to hide the data, the data is contained in the class variables. So, option (d) using private access modifier on the class fields is correct option. Option (A) is wrong as the using the public access modifier doesn't hide anything. It is public and is visible to the public. Option (B) is wrong as using the private access modifier on the methods means it is hiding the implementation of the methods not the data. Option (C) is wrong as using private access modifiers on class definition means making the classes not visible to other classes it doesn't mean data hiding as the data is contained in the class variables.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Data hiding, which means that critical data stored inside the object is protected from code outside the object, is accomplished in Java by: ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers