Question:

In object-oriented programming, what is encapsulation?

Show Hint

Encapsulation is about hiding the internal details of an object and providing controlled access to its properties and methods.
Updated On: Jun 27, 2025
  • Combining data and methods into a single unit
  • Hiding the implementation details of a class
  • Inheriting properties from a parent class
  • Allowing multiple forms of a method
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is B

Solution and Explanation

In object-oriented programming (OOP), encapsulation refers to the practice of bundling the data (variables) and the methods (functions) that operate on that data into a single unit called a class. It also involves restricting access to some of the object's components, which is often done by making some properties or methods private, thereby hiding the internal implementation details from the outside world.
- Combining data and methods into a single unit (A) is a general description of encapsulation, but the focus is on hiding implementation details (B).
- Inheriting properties from a parent class (C) refers to inheritance, not encapsulation.
- Allowing multiple forms of a method (D) refers to polymorphism, not encapsulation.
Thus, the correct answer is (B).
Was this answer helpful?
0
0