OOP consists of following features:-
Grady Booch, a famous author who has written many books on Object Oriented Programming (OOP) has defined the abstraction, encapsulation features as,
- An abstraction defines the essential characteristics of an object that distinguishes it from all other kinds of objects and thus provides crispy defined conceptual boundaries, relative to the perspective of the viewer.
- In this, it hides private implementations behind the public interfaces.
- Suppose we want to buy a refrigerator then we will concentrate only on the advertisement which will featuring of refrigerator, we will not concentrate on the other products like vacuum cleaner, washing machine.
- So from above if we have to implement an Abstraction, we also have to implement the features of an Encapsulation.
- Because, an Encapsulation hides the irrelevant details and an abstraction shows relevant details.
- An Encapsulation is a process of hiding all of the details of an object that do not contribute to its essential characteristics.
- An Encapsulation is also called as an Information hiding.
- Means it hides the non essential characteristics from the user.
- Computer games use the features of an Encapsulation. The user need know that, how to play the game. So, all the complex work of those games are hidden from the user.
- An anytime money ATM which uses the feature of an Encapsulation. i.e. when we insert a card in the machine it provides a pin code. The only access you have to the ATM is to provide the pin to your account and not to the process of validating the password.
- If your pin code is correct then you can access your account from ATM.
- So all the process happened behind the ATM is encapsulated.
- In an Object Oriented Programming (OOP), Inheritance defines the reusability.
- Suppose there is an existing class and you have to use it then you can re use it by using an Inheritance by extending that class.
- i.e. Inheritance defines one class acquires the property of another class.
- Polymorphism defines one or more form i.e. polymorphism is the feature that enables you to assign a different meaning to entity in different contexts.
- Suppose a person who plays different roles in his life like child to his parents, father to his children, husband to his wife, employee for his company, etc.