1Z0-809 · Question #126
Which statement best describes encapsulation?
The correct answer is A. Encapsulation ensures that classes can be designed so that only certain fields and methods of an object are accessible from other objects. Encapsulation is the OOP principle of bundling data and behavior inside a class while controlling what the outside world can access - option A captures this precisely with "only certain fields and methods are accessible from other objects," which is enforced through access…
Question
Options
- AEncapsulation ensures that classes can be designed so that only certain fields and methods of an object are accessible from other objects.
- BEncapsulation ensures that classes can be designed so that their methods are inheritable.
- CEncapsulation ensures that classes can be designed with some fields and methods declared as abstract.
- DEncapsulation ensures that classes can be designed so that if a method has an argument MyType x, any subclass of MyType can be passed to that method.
How the community answered
(33 responses)- A76% (25)
- B3% (1)
- C6% (2)
- D15% (5)
Explanation
Encapsulation is the OOP principle of bundling data and behavior inside a class while controlling what the outside world can access - option A captures this precisely with "only certain fields and methods are accessible from other objects," which is enforced through access modifiers like private, protected, and public.
- B is wrong because method inheritance describes inheritance, not encapsulation.
- C is wrong because abstract fields/methods describe abstraction, a separate OOP pillar.
- D is wrong because passing subclass instances where a parent type is expected describes polymorphism (specifically the Liskov Substitution Principle).
Memory tip: Think of encapsulation as a capsule (like a pill) - the medicine (data) is sealed inside, and only the outer coating (public interface) is exposed. If you can control who sees what, that's encapsulation.
Community Discussion
No community discussion yet for this question.