Question:medium

What is the meaning of encapsulation in Object Oriented Programming?

Show Hint

Encapsulation is like a capsule for medicine. The plastic shell (the class) bundles the medicine (the data) and protects it from the outside world. You interact with it through a controlled interface (by swallowing it), not by directly touching the raw ingredients.
Updated On: Jul 2, 2026
  • Avoiding class usage
  • Using only public methods
  • Allowing global access to variables
  • Hiding implementation details
Show Solution

The Correct Option is D

Solution and Explanation

Step 1: Picture a real-world capsule for a moment.
Just as a medicine capsule wraps its contents so you only ever interact with the outer shell, encapsulation in object oriented programming bundles an object's data together with the methods that work on that data into one single class.
Step 2: Add the access-control layer on top of bundling.
Beyond simply bundling things together, encapsulation also restricts direct access to the internal state by marking data members private and exposing only carefully chosen public methods, commonly called getters and setters, to read or change them safely.
Step 3: Connect this back to the given option.
Because the internal representation and working details stay private and shielded from outside code, the object effectively hides how it does its job while still offering a clean public interface, which is exactly the idea of hiding implementation details.
\[ \boxed{\text{Hiding implementation details}} \]
Was this answer helpful?
0