Which object-oriented design principle restricts outside code to a module’s…

2023

Which object-oriented design principle restricts outside code to a module’s published interface by hiding its internal representation?

Answer: B. Information hidingConcept. Object-oriented design separates its core principles by the question each one answers about a module. Visibility — how much of a module the code…

  1. A.

    Polymorphism

  2. B.

    Information hiding

  3. C.

    Encapsulation

  4. D.

    Abstraction

Attempted by 88 students.

Show answer & explanation

Correct answer: B

Concept. Object-oriented design separates its core principles by the question each one answers about a module. Visibility — how much of a module the code outside it may see and reach — is governed by information hiding: a module keeps its internal representation to itself and publishes only a set of operations, so client code is written against that published interface and never against the stored details. The remaining principles answer different questions: grouping (which members are packaged together as one unit), modelling (which features of an entity are represented at all), and dispatch (how one operation name resolves to several behaviours).

Application. The stem fixes the axis with the phrases “restricts outside code to a module’s published interface” and “hiding its internal representation”: it asks which principle controls an access boundary between a module and its clients. That is the visibility question, so the principle being described is information hiding. In C++ the mechanism is the access specifier — a member declared under private can be named only from inside the class itself and from its friends, a member declared under protected is additionally reachable from derived classes, and only the members declared under public are available to unrelated outside code. A class built this way publishes the operations its clients genuinely need and keeps its stored representation out of their reach.

Contrast with the near neighbours.

Principle

What it governs

How it shows up in C++

Information hiding

Visibility: how much of a module outside code may reach

the private and protected access specifiers

Abstraction

Modelling: which features of an entity are represented at all

which members a class declares; an abstract base class fixing pure virtual operations

Encapsulation

Packaging: which data and functions are bound into one unit

the class declaration, listing data members and member functions together

Polymorphism

Dispatch: how one operation name resolves to several behaviours

overloading resolved during compilation; virtual functions resolved while the program runs

The original source wording can resemble textbook descriptions of abstraction, which often speak of showing only essential features. The clarified wording resolves that overlap by explicitly naming a published interface, an internal representation, and a restriction on outside access. Abstraction settles which features a class models; information hiding settles how much of the class its clients may reach. The source Bihar STET Computer Science paper records Information hiding as the right answer.

Cross-check. Read the stem the other way round. Take a C++ class and move every one of its members into a public section: the class is still an abstraction of its entity, its data and functions are still packaged into one unit, and its virtual functions still dispatch polymorphically. The single guarantee that has been lost is that outside code sees only what the class chose to publish — so that guarantee is the one the stem is describing.

Answer: Information hiding.

Explore the full course: Bpsc

Loading lesson…