Question
Which OOP concept ensures that the internal details of
an object are hidden from the outside world, providing a clear interface for interaction?Solution
Encapsulation is a cornerstone of OOP that enforces data hiding by restricting direct access to an object’s internal state. 1. Data Protection: By using access modifiers (e.g., private, protected), encapsulation shields sensitive data from external manipulation. 2. Clear Interfaces: Through getter and setter methods, encapsulation provides controlled interaction with an object’s data, ensuring integrity and security. 3. Modularity: Encapsulation helps developers manage code complexity by compartmentalizing data and behavior within distinct classes. Thus, encapsulation creates a robust framework for managing dependencies and ensuring secure object interactions. Why Other Options Are Incorrect: • A) Abstraction: Focuses on hiding implementation details but differs by emphasizing interface design. • B) Polymorphism: Deals with dynamic behavior and method variability, unrelated to data hiding. • D) Inheritance: Describes property/method sharing between classes, not encapsulation. • E) Composition: Involves constructing objects using other objects, unrelated to access control.
Six persons N, O, P, Q, R and S sit in a linear row facing north. R is second to the left of N. Two persons sit to the right of S. Q sits immediate left...
Which of the following is true?
Six tractors KZ, MZ, OZ, QZ, SZ, and UZ are parked around a circular parking space facing towards the centre (not necessarily in the same order). QZ is ...
Who among the following sits second to the left of B?
Who is from Kolkata?
Six students M, N, K, E, S and G are sitting in a circle facing each other such that N sits to the immediate right of K. M does not sit near G. The stud...
How many seats are between M and S when counted from the left of S?
Five products, P, Q, R, S and W, are placed in a row facing towards the east (not necessarily in the same order). R is second to the left of S. P is sec...
Which of the following statements is true?
Five people, H, I, J, K, and L, are sitting in a straight row, facing north. I sits to the immediate left of K. Only three people sit between J and L. H...