Question
Which OOP principle allows for restricting access to
certain parts of an object while exposing only necessary parts for interaction?Solution
Encapsulation is a fundamental principle of OOP that involves bundling data (attributes) and methods (functions) that operate on the data into a single unit or class. It also restricts direct access to some components of the object, typically by declaring them private or protected. Access is then controlled through public methods known as getters and setters. Encapsulation ensures security and prevents unauthorized or accidental modification of data. For instance, in a class BankAccount , the balance attribute might be private, and only specific methods like deposit() or withdraw() are accessible to modify it. This safeguards the integrity of the data and prevents incorrect usage. Why Other Options Are Wrong Option A : "Polymorphism" Polymorphism deals with methods behaving differently for different object types, not with restricting access. Option C : "Inheritance" Inheritance allows a child class to use the properties and methods of a parent class but does not involve controlling access to data. Option D : "Abstraction" Abstraction hides complexity by exposing only essential features. However, encapsulation is specifically about access control at the data and method level. Option E : "Message Passing" Message passing refers to the communication between objects in OOP but does not control access to internal object components.
What step has the Reserve Bank of India (RBI) taken to ease the liquidity crunch in the banking system?
What major innovation did Woolah Tea of Assam introduce, which earned a 20-year patent?Â
Where did ISRO conduct the main parachute test for the Gaganyaan crew module?Â
How many countries and international organisations endorsed the New Delhi Declaration at the AI Impact Summit 2026?Â
What is the significance of the International Volunteers Day observed on December 5th?
Moldova became the ____ member country of the International Solar Alliance (ISA) in 2025.Â
What was a key factor contributing to the easing of India's retail inflation to 5.5% in November 2024?
Which state in India houses the country's first dinosaur museum?
What ensures uninterrupted connectivity between Kashmir and Ladakh during winters in the Z-Morh tunnel?
Consider the following statements regarding the retirement of Ruchira Kamboj:
1. Ruchira Kamboj was the first woman to become the Indian Ambass...