IGDTUW 2025 — Computer PYQ
IGDTUW | Computer | 2025Which concept allows you to hide the inner workings of a class and only show what is necessary to the user?
Choose the correct answer:
- A.
Compilation
- B.
Inheritance
- C.
Encapsulation
(Correct Answer) - D.
Loops
Encapsulation
Explanation
The correct answer is (c) Encapsulation.
Explanation
Encapsulation is a fundamental principle of Object-Oriented Programming (OOP) that involves bundling the data (attributes) and the methods (functions) that operate on that data into a single unit, known as a class. A key aspect of encapsulation is data hiding, where the internal state of an object is hidden from the outside world and can only be accessed through well-defined public interfaces (methods).
By restricting direct access to the internal data, encapsulation protects the object's integrity and allows the internal implementation to change without affecting the code that uses the object.
Conceptual Mathematical Model
If we define the total complexity of a class as Ctotal, it is composed of internal hidden implementation Ihidden and the public interface Ipublic:
Ctotal=Ihidden+Ipublic
The principle of encapsulation ensures that the user of the class interacts only with the interface:
Interaction=Ipublic
This effectively hides the Ihidden complexity from the end user, maintaining a clean abstraction.
