Interface and Abstraction

A brief introduction to interfaces and abstraction along with some interactive examples is provided in this lesson.

Understanding object-oriented programming concepts is extremely important. Understanding the idea of abstraction in object-oriented programming is compulsory.

Using Interface in object-oriented programming is really tricky. The concept demands more attention than it seems. We have already seen some examples of abstraction or encapsulation. A class is a good example of abstraction. It encapsulates every detail from the users. Users do things with objects without knowing what is happening behind the scenes or how it was designed in a blueprint.

The interface takes the concepts of abstraction to a higher level. Let’s look at a concrete example to understand how it works.

Coding example: 88

Suppose a school wants to measure the weight of every student for medical purposes. The school authority hires a contractor and gives them the contract. The school authority does not care how the work will be done. They want records and the contract is implemented. The students don’t know why their weights are taken. Now, this contract can be implemented in other spheres. A book company might want to compare the number of pages of the books they have published. They can also implement this.

Get hands-on with 1200+ tech skills courses.