KnowledgeBoat Logo

Computer Applications

'Encapsulation reduces the complexity and makes the system easier'. Explain this statement with a real world example.

OOP Intro Java

25 Likes

Answer

Encapsulation means wrapping of data and methods into a single unit and restricting direct access to some of the object's components.

Let us take the example of an ATM machine. When we want to withdraw money from an ATM machine, we swipe our card, enter the pin and then enter the amount of money we want to withdraw. The ATM machine processes our request and gives us the required money.

Here, money is treated as data and the various processes such as verification of the authenticity of the user, pin and balance in the account etc., are the methods. The data and methods are encapsulated in the ATM (which is treated as a class). Since the user doesn't have to understand the actual working of the ATM machine, encapsulation reduces the complexity and makes the system (ATM machine) easier to use.

Answered By

15 Likes


Related Questions