Computer Applications
'Encapsulation reduces the complexity and makes the system easier'. Explain this statement with a real world example.
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.
Related Questions
Which of the Object Oriented programming principles explain the following illustrations? Justify.
(a) The variables and methods are put together in a Class.
(b) A man withdrawing money from ATM.
Give two differences between Data Hiding and Encapsulation.
Give two differences between Procedure Oriented languages and Object Oriented languages.
What is meant by Data Hiding?