Ask Question
9 May, 23:18

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 May, 02:45
    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?
Find 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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers