The mechanism that binds code and data together and protects them from direct…

2012

The mechanism that binds code and data together and protects them from direct access by the outside world is known as:

Answer: C. EncapsulationConceptIn object-oriented programming, encapsulation groups state (data) and the methods that operate on that state within one unit, such as a class. It also…

  1. A.

    Abstraction

  2. B.

    Inheritance

  3. C.

    Encapsulation

  4. D.

    Polymorphism

Attempted by 4 students.

Show answer & explanation

Correct answer: C

Concept

In object-oriented programming, encapsulation groups state (data) and the methods that operate on that state within one unit, such as a class. It also controls direct access to the internal state through a defined interface.

Application

The stem describes both bundling code with data and restricting outside access. These are the two defining aspects of encapsulation, so the required term is Encapsulation.

Contrast

  • Abstraction exposes essential features while hiding implementation complexity.

  • Inheritance creates a derived class from an existing class so that state and behavior can be reused or extended.

  • Encapsulation combines related state and behavior and controls access to the state.

  • Polymorphism allows the same interface or operation to have different implementations for different object types.

Cross-check

If the stem asked only about exposing essential features, abstraction would fit; if it asked about deriving a class, inheritance would fit; and if it asked about one interface with multiple implementations, polymorphism would fit. The combined clues of bundling and access control identify encapsulation.

Result

Encapsulation.

Explore the full course: Nta Ugc Net Paper 2

Loading lesson…