Java Programming

Java – Abstraction in Java Programming

Abstraction is the mechanism by which you hide data that is not required by a user.

The advantage of abstraction is that the user can work only with the needed data and is not required to view the unwanted data. i.e the owner of the car must know how to drive.

In OOPs, you must have to know about specific classes and methods that are called to implement specific program logic.

Java Source

public class Abstraction {
private int x;
private String str;
private double bal;
private double sal;
private double credit;

public void display(int n, String name, double bal){
x=n;
str=name;
bal=bal;
System.out.println("Account Number:"+x);
System.out.println("Name:"+str);
System.out.println("Balance:"+bal);

}
public static void main(String[] args) {
Abstraction b=new Abstraction();
b.display(111, "Satya", 232323l);
}

}

Back to top button

Adblock Detected

Please turn off your Adblocker to view your content.