Encapsulation is

2009

Encapsulation is

  1. A.

    Dynamic binding

  2. B.

    A mechanism to associate the code and data.

  3. C.

    Data abstraction

  4. D.

    Creating a new class

Attempted by 1 students.

Show answer & explanation

Correct answer: B

Concept

Encapsulation is one of the core pillars of object-oriented programming, alongside abstraction, inheritance, and polymorphism. It is the mechanism of bundling the data (attributes/state) of an object together with the methods (functions/behaviour) that operate on that data into a single unit — typically a class — while controlling outside access to the internal state through access modifiers such as private, protected, and public.

Application

The stem asks what encapsulation fundamentally is. Checking each option value against this definition, the value "a mechanism to associate the code and data" states exactly this bundling of data together with the code (methods) that act on it inside one unit. This matches the standard definition of encapsulation used across object-oriented languages such as C++, Java, and C#.

Cross-check

  • Dynamic binding is the run-time resolution of which method implementation executes, based on the object’s actual type rather than its compile-time type — this is the mechanism behind runtime polymorphism, not encapsulation.

  • Data abstraction is about exposing only the essential features or interface of an object to the outside world while hiding the underlying implementation complexity — a related but distinct pillar that emphasises hiding complexity rather than bundling data with code.

  • Creating a new class describes defining a new class — a template that specifies the attributes and behaviours objects of that type will have. This is the basic mechanism by which a type is introduced in object-oriented programming, not the bundling of data with code that defines encapsulation.

Since only the "bundling data with code into a single unit" description matches the standard definition of encapsulation, that option value is the correct answer.

Explore the full course: Nta Ugc Net Paper 2

Loading lesson…