Abstraction is the concept of exposing only the required essential characteristics and behavior concerning a context.

The hiding of data is known as data abstraction . In an object-oriented programming language, this is implemented automatically while writing the code in the form of class and object.

Real-Life Example of Abstraction in Java

Abstraction shows only important things to the user and hides the internal details, for example, when we ride a bike, we only know about how to ride bikes but can not know about how it works? And also we do not know the internal functionality of a bike.
Another real-life example of Abstraction is ATM Machine; All are performing operations on the ATM like cash withdrawal, money transfer, retrieve mini-statement…etc. but we can't know internal details about ATM. 

Difference Between Encapsulation and Abstraction in Java

Abstraction deals with hiding the details and showing the essential things to the user whereas encapsulation binds your data and code together as a single unit.

Encapsulation is not providing full security because we can access private members of the class using reflection API, but in the case of Abstraction we can't access static, abstract data members of a class.

In java, you can say it takes all your methods, variables and bind them together in a single class.

Abstraction is implemented in Java using an interface and abstract class while Encapsulation is implemented using private, package-private, and protected access modifiers.

Advantages of Data Abstraction in Java

Here we discuss some of its benefits to acknowledge its significance. The benefits of data abstraction are given below;

  • Data abstraction increases the reusability of the code by avoiding any chances of redundancy.
  • It increases the readability of the code as it eliminates the possibility of displaying the complex working of the code.
  • With the implementation of classes and objects, comes enhanced security. Since data abstraction is a method of implementing classes and objects denying access to other classes of accessing the data members and member functions of the base class.
  • It helps the user to write high-level code.
  • It separates the entire program into code and implementation making it more comprehensible.
  • Helps the user to avoid writing low-level code.
  • Avoids code duplication and increases reusability.
  • Can change the internal implementation of class independently without affecting the user.
  • Helps to increase the security of an application or program as only important details are provided to the user.

Program:

class Customer { int account_no; float balance_Amt; String name; int age; String address; void balance_inquiry() { /* to perform balance inquiry only account number is required that means remaining properties are hidden for balance inquiry method */ } void fund_Transfer() { /* To transfer the fund account number and balance is required and remaining properties are hidden for fund transfer method */ }

Output:


  • Progamming is what actually means ?
  • What is software development ?
  • How we categorized software development in different manner.
C Programming
C Plus Plus
Python
Java Development
Web Designing
Javascript
Mysql
Oracle
We cover all the programming concepts in various programming languages, this tutorials are very help full for bigener as well as Experience developer, for the ease of understanding we categorized programming in different manner likewise.