IPA FE Subject A sample Question 38

A question IPA Japan published in 基本情報技術者試験 科目A サンプル問題 問38, translated into English. ITPEC is based on the same exams.

In an object-oriented program, which of the following is the name of combining data and methods into one and making the details of the implementation of an object invisible to users?

Explanation

Encapsulation — bundling an object’s data with the methods that work on it, and hiding how it is implemented.

In an encapsulated class the attributes are private and other code reaches them only through the class’s public methods. Users of the object see what it does, not how: the internal data layout and logic can change without affecting them, and the data cannot be put into an invalid state from outside. This hiding of the inside is also called information hiding.

Answer (b)

Why not others:

  • •(a) Instance — a concrete object created from a class, not a way of hiding its implementation
  • •(c) Clustering — grouping similar items together (in data analysis, or servers in a cluster); not an object-oriented concept
  • •(d) Abstraction — picking out the common, essential properties of things and ignoring the rest, as when a class is defined; it is about what to model, not about bundling and hiding

Key rule: Encapsulation = data and methods in one unit with the inside hidden; inheritance = reusing a superclass; polymorphism = one message, behavior chosen by the class.

System Development Technology · AI-written, may contain errors

This question comes from the past questions IPA Japan publishes, translated into English by ITPEC Practice. ITPEC Practice is an independent study tool and is not affiliated with IPA or ITPEC. See the original paper (PDF) or Report an issue.