Java SE 8 Programmer I — Question 55
What is the name of the Java concept that uses access modifiers to protect variables and hide them within a class?
Answer options
- A. Encapsulation
- B. Inheritance
- C. Abstraction
- D. Instantiation
- E. Polymorphism
Correct answer: A
Explanation
The correct answer is Encapsulation, which refers to the concept of restricting access to certain components of an object, thereby protecting the internal state of the class. Inheritance, Abstraction, Instantiation, and Polymorphism are different principles in object-oriented programming that do not specifically focus on the protection and hiding of variables.