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.
A train travelling at the speed of 72 km/hr crosses another train, having 60 meters less length and travelling in opposite direction at the speed of 54 ...
Train M, ‘x’ metres long crosses (x – 30) metres long platform in 24 seconds while train N having the length (x + 30) metres crosses the same plat...
Train A takes 90 seconds to cross a telegraph pole by travelling at 18 kmph speed. Train B has its length 60% more than A. It takes 40 seconds to cross ...
Gatiman express train crosses a platform in 23 seconds while it can cross a pole in 10 seconds. If the speed of the Gatiman express is 25 m/s, then find...
A train takes 5 seconds more to cross a 180-metre-long platform than it takes to cross a pole. If a car running at the speed of 42 m/s takes 80 seconds ...
Two trains A and B, were proceeding in the same direction on parallel tracks at 20 km/hr and 74 km/hr respectively. A man noticed that it took exactly 1...
100 metre long train ‘A’ can cross a platform of length 50 metres in 20 seconds. If the speed of train ‘B’ is 6 m/s more than that of train ‘A...
A train is running with the speed of 72 kmph crosses a pole in 25 sec. In how much time it can cross a 160 m long platform?
A train has to cover a distance of 112 km in 14 hours. If it covers half journey in 3/5th time, then the speed of covering the remaining dist...
Two trains approach each other at 22 kmph and 26 kmph from 2 places 240 km apart. After how many hours they will meet?