What is Data Abstraction in OOPS?

What is Abstraction in OOPs? Learn with Java Example


What is Abstraction in OOP?

Abstraction is selecting data from a larger pool to show only the relevant details to the object. It helps to reduce programming complexity and effort. In Java, abstraction is accomplished using Abstract classes and interfaces. It is one of the most important concepts of OOPs.

Click here if the video is not accessible 

Let’s Study Abstraction concept with an Example

Suppose you want to create a banking application and you are asked to collect all the information about your customer. There are chances that you will come up with following information about the customer

What is Abstraction in OOPS?

But, not all of the above information is required to create a banking application.

So, you need to select only the useful information for your banking application from that pool. Data like name, address, tax information, etc. make sense for a banking application

What is Abstraction in OOPS?

Since we have fetched/removed/selected the customer information from a larger pool, the process is referred as Abstraction.

However, the same information once extracted can be used for a wide range of applications. For instance, you can use the same data for hospital application, job portal application, a Government database, etc. with little or no modification. Hence, it becomes your Master Data. This is an advantage of Abstraction.

How to achieve Abstraction?

Abstraction in Java can be achieved using Abstract Class and Abstract Method.

Abstract Class

A class which is declared “abstract” is called as an abstract class. It can have abstract methods as well as concrete methods. A normal class cannot have abstract methods.

Abstract Method

A method without a body is known as an Abstract Method. It must be declared in an abstract class. The abstract method will never be final because the abstract class must implement all the abstract methods.

Welcome to Our Website
Welcome to WPBot