nerdexam
Oracle

1Z0-808 · Question #50

QUESTION 61 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. Option A is correct because encapsulation is the OOP principle of bundling data (fields) and behavior (methods) within a class while restricting direct external access - typically through access modifiers like private, protected, and public. This "data hiding" lets you control…

Working with Methods and Encapsulation

Question

QUESTION 61 Which statement best describes encapsulation?

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

(31 responses)
  • A
    94% (29)
  • B
    3% (1)
  • C
    3% (1)

Explanation

Option A is correct because encapsulation is the OOP principle of bundling data (fields) and behavior (methods) within a class while restricting direct external access - typically through access modifiers like private, protected, and public. This "data hiding" lets you control exactly what other objects can see and interact with.

Why the others are wrong:

  • B describes inheritance, not encapsulation - the ability for subclasses to inherit methods from a parent.
  • C describes abstraction - specifically the use of abstract classes/methods to define contracts without full implementation.
  • D describes the Liskov Substitution Principle (a pillar of polymorphism), where a subtype can stand in for its parent type.

Memory tip: Think of encapsulation as a capsule (like a pill) - the internals are sealed off from the outside. You interact only through the exposed surface (public methods), not the hidden contents (private fields).

Topics

#encapsulation#access control#data hiding#OOP principles

Community Discussion

No community discussion yet for this question.

Full 1Z0-808 Practice