Question
Which of the following best illustrates Encapsulation
in Object-Oriented Programming?Solution
Encapsulation is a key OOP principle that involves combining data (fields) and methods (functions) into a single unit (class) and controlling access to them using access modifiers like private, protected, and public. For instance, a BankAccount class might hide its balance field (using private access) and expose methods like deposit() and withdraw() to manipulate it. Encapsulation ensures data integrity and security , preventing unauthorized access or modifications. Why Other Options Are Incorrect : 2. Allowing multiple objects to interact through message passing : This describes Message Passing , which focuses on communication between objects. 3. Hiding complex implementation details from the user : This is Abstraction , not Encapsulation. 4. Enabling a class to inherit properties and methods from another class : This refers to Inheritance , unrelated to Encapsulation. 5. Defining a one-to-many relationship between objects : This aligns with Aggregation or Composition , not Encapsulation.
In which state is the Rihand Dam located?
What was India's industrial production (IIP) growth in April 2025, the lowest in eight months?
From 1st October 2025, which UPI feature will be discontinued to curb frauds?Â
What is the core objective of Andhra Pradesh’s Green Hydrogen Valley Declaration 2025?Â
- Who is the only Indian woman featured in Time Magazine's Women of the Year 2025 list?
Which state announced the formation of Kalyan Singh Nagar, becoming its 76th district?Â
According to the World Gold Council (WGC), which country was the largest buyer of gold in 2024?
The First International Conference on Green AI is scheduled to be held at which venue?Â
In July 2025, what was the FAO Food Price Index value?Â
What is the name of India’s newly inducted mobile counter-drone system by DRDO?