Abstraction in JAVA

As we saw previously abstraction is an important pillar of object orientation.  In Java, Abstraction Means we will only show the necessary functionalities to the user to perform some task and we will hide the critical code.

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

In Real Time, when you go to any ATM Machine it shows you several options while doing any transaction like Withdraw, Balance Inquiry, Transfer, mini statement, Deposit, and Much More.

In this, All the functionalities user only knows that What this Functions/ options do, But don’t know that how does it Work in the background, What code is there in backend or which language it uses.maxresdefault

It provides the Security features as in hides the important code behind it from unauthorized Methods/ Functions.

Example

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 */
}

class AtmWindow{
Public static void main( String[] args ){

Customer c = new Customer();

c.balance_inquiry();
}
}

 

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Powered by WordPress.com.

Up ↑

%d bloggers like this: