Abstraction

Learn to hide the data with the abstraction technique in OOP.

Definition

Abstraction is a technique used in object-oriented programming that simplifies the program's structure. It focuses only on revealing the necessary details of a system and hiding irrelevant information to minimize its complexity. In simpler words, we can say that it means to show what an object does and hides how it does it.

Example

There are countless real-life examples that follow the rules of abstraction. Take the "volume" button on a television remote. With one click, we can increase the TV’s volume. Let’s say the button calls the volumeUp() function. The TV responds with a sound louder than before. We are oblivious to the fact that the inner circuitry of the TV implements this, but we know how the exposed function interacts with the TV's volume.

Another instance of abstraction is our daily use of vehicles. To our general knowledge, the race peddle tells the car to consume fuel and increase its speed. We do not need to understand the mechanical process.

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.