1Z0-808 · Question #40
What is the name of the Java concept that uses access modifiers to protect variables and hide them within a class?
The correct answer is A. Encapsulation. Encapsulation is the Java concept that uses access modifiers (private, protected, public) to restrict direct access to a class's variables, typically exposing them only through getter/setter methods - exactly what the question describes. B. Inheritance is wrong - it's about one…
Question
Options
- AEncapsulation
- BInheritance
- CAbstraction
- DInstantiation
- EPolymorphism
How the community answered
(37 responses)- A92% (34)
- C3% (1)
- E5% (2)
Explanation
Encapsulation is the Java concept that uses access modifiers (private, protected, public) to restrict direct access to a class's variables, typically exposing them only through getter/setter methods - exactly what the question describes.
- B. Inheritance is wrong - it's about one class acquiring properties/methods from another (parent-child relationships).
- C. Abstraction is wrong - it's about hiding implementation complexity behind interfaces or abstract classes, not protecting data fields.
- D. Instantiation is wrong - it simply means creating an object from a class using
new. - E. Polymorphism is wrong - it refers to objects taking multiple forms (method overriding/overloading), unrelated to access control.
Memory tip: Think "encapsulate = capsule = sealed container." Just as a pill capsule protects its contents from the outside, encapsulation wraps and protects a class's data from direct external access.
Topics
Community Discussion
No community discussion yet for this question.