An important element of object oriented programming is abstraction. Abstraction is basically managing the complex activities with out knowing the details. For e.g., when we call some one using the mobile, there are lot of operations which happen in the background, before the call reaches the other person. We need not know any of that information, but still be able to make a call.
This is how we manage most of the activities in real life like driving the car with out knowing how the engine works or brake works. Travelling on the train with out knowing who the driver is, or how the railway signalling works. Because we do so many actions, it is not necessary to understand every detail of every action we do.
Similarly, in programming we use complex systems - with lots of packages, classes and methods. It is not necessary to know every detail of those systems, we can check what interfaces it provides and use them effectively. If we take the mobile network, only thing we need to know is how to get a new SIM card, how to make a call, how to receive a call and how to recharge the amount. The other details of how the signalling tower works, how the money paid for recharge at the local shop reaches the mobile operator and how the mobile operator keeps track of the number of minutes/seconds you have used are not necessary. If we are the users of the factorial method in Factorial Program In Java Using While Loop, then you need not know whether the method internally uses for loop or while loop. As long as the method gives the proper factorial of the given input value, you need not worry about the internals. This is a good example of abstraction or abstracting the details of a process.
Similarly, in the Bank account's example seen in Future Task Java Program Using Interfaces, we can do the operations like deposit , withdraw with out knowing how the methods are implemented.
Below mentioned are three major principles of object oriented programming:
|