Abstraction is mechanism by which we hide data that is not required by a user.The Advantage of abstraction is that user can work only with required Data and does not need to view unwanted Data;
Let's take the example of the Car to understand the concept of abstration .
As the owner of the car, you must know how to drive it.This obviously implies that you know about the various components of the car and how to use them.
For Example, you know that the accelerator pedal is use to increase the speed of the car and pressing the brake pedal stop it.To perform these simple action ,you just need to know how to use these component, and not hoe the function.
Similarly , in OOP , you need to know about the spacifi classes or meethod that are called to implement spacific program logic, with know these class or method.
This Concept is Called abstraction.
Example Code:
Abstraction.java
public class Abstraction {
int id;
String name;
String Clas;
public void information(int roll,String nm,String clas){
id=roll;
name=nm;
Clas=clas;
System.out.println("Student Roll Number: "+id);
System.out.println("Student Name is: "+name);
System.out.println("Student Class is: "+Clas);
}
}
AbstractImplementatiom.java
public class AbstractImplementatiom {
public static void main(String[] args)
{
Abstraction ab=new Abstraction();
ab.information(3, "tomy", "BS:SE");
}
}
Let's take the example of the Car to understand the concept of abstration .
As the owner of the car, you must know how to drive it.This obviously implies that you know about the various components of the car and how to use them.
For Example, you know that the accelerator pedal is use to increase the speed of the car and pressing the brake pedal stop it.To perform these simple action ,you just need to know how to use these component, and not hoe the function.
Similarly , in OOP , you need to know about the spacifi classes or meethod that are called to implement spacific program logic, with know these class or method.
This Concept is Called abstraction.
Example Code:
Abstraction.java
public class Abstraction {
int id;
String name;
String Clas;
public void information(int roll,String nm,String clas){
id=roll;
name=nm;
Clas=clas;
System.out.println("Student Roll Number: "+id);
System.out.println("Student Name is: "+name);
System.out.println("Student Class is: "+Clas);
}
}
AbstractImplementatiom.java
public class AbstractImplementatiom {
public static void main(String[] args)
{
Abstraction ab=new Abstraction();
ab.information(3, "tomy", "BS:SE");
}
}