What is an abstraction in OOP?
In general, the abstraction is the act of removing characteristics from something in order to reduce it to a set of essential functions or characteristics.
In Object Oriented Programming abstraction concept the actual implementation is hidden from the user and only required functionality will be accessible or available to the user.
Abstraction is a powerful methodology to manage complex systems. Abstraction is managed by well-defined objects and their hierarchical classification.
The abstraction concept is mainly used in the project design level, here in program design, what features a program will contain is declared but not how to implement the features.
Abstraction in OOP Example
For example: consider an ATM machine, you might have used ATM machine many times for cash withdrawal and bank statements. The ATM machine has given a card swipe slot, a touch screen and a keyboard, you can use these features to withdraw the money but you never will know what exact actions or operations takes place internally in the machine like after card swipe the machine check whether the card is valid or not, then the PIN will be verified if it is correct then only we can withdraw the money.
Another example of abstraction is a watch, you checks the time many times in a day but you never need to know what the internal mechanism of the watch is.
In OOP programming language like the Java, abstraction can be achieved by interface and abstract class.
interface Vehicle { public abstract int topSpeed(); public abstract float mileage(); }
In the above example we can see WHAT function an implementing class will contain but we cannot see HOW the function is implemented.