nerdexam
Oracle

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…

Working with Methods and Encapsulation

Question

What is the name of the Java concept that uses access modifiers to protect variables and hide them within a class?

Options

  • AEncapsulation
  • BInheritance
  • CAbstraction
  • DInstantiation
  • EPolymorphism

How the community answered

(37 responses)
  • A
    92% (34)
  • C
    3% (1)
  • E
    5% (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

#encapsulation#access modifiers#data hiding#OOP principles

Community Discussion

No community discussion yet for this question.

Full 1Z0-808 Practice