In object-oriented design, which concept best matches “exposing only the necessary information to the client and hiding the rest”? Pick the most appropriate OOP term.

Difficulty: Easy

Correct Answer: Abstraction

Explanation:

Introduction:Good APIs reveal just enough to use a component while keeping internal complexity hidden. This question checks whether you can identify the OOP concept that emphasizes presenting essential features and omitting unnecessary details from a user’s perspective.

Given Data / Assumptions:

  • Client consumes a type via its public interface.
  • Internal representation and helper functions remain hidden.
  • Terms like encapsulation, data hiding, and abstraction are related but distinct.

Concept / Approach:Abstraction focuses on modeling only the relevant aspects and exposing a clean interface, independent of implementation. Encapsulation is about bundling data and behavior with access control; data hiding is the access-control manifestation that prevents outsiders from touching internals. Abstraction is the closest match to “exposing only what’s necessary”.

Step-by-Step Solution:1) Identify the goal: minimize surface area and reveal essential operations.2) Map to OOP terms: this is abstraction at the API boundary.3) Use encapsulation and data hiding to support the abstraction (private members, friend minimization).4) Result: clients program to an abstract interface, not concrete details.

Verification / Alternative check:Compare a well-designed class with a leaky one. The former exposes methods like push/pop/top for a stack while hiding its internal container choice, demonstrating abstraction.

Why Other Options Are Wrong:Encapsulation: supporting mechanism; broader than “expose only what’s necessary.”Data hiding: narrower focus on access control rather than conceptual modeling.Data binding: unrelated term in OOP contexts here.

Common Pitfalls:Using abstraction and encapsulation interchangeably; abstraction is about the interface level, while encapsulation is about packaging and access control.

Final Answer:Abstraction

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion