I am trying to understand the difference between Data abstraction and procedural abstraction in java.
I understand the procedural abstraction is making use of methods that accept formal parameters and hiding the implementation from the user. This totally makes sense in PL/SQL
language as I have an option of creating procedures separately in PL/SQL
.
But I get confused between Data abstraction and Procedural abstraction, as even the procedures in Java are implemented as part of some class. And every class can also have some static methods(public static
) which every other class in the package can use.
Please can someone give a clear distinction between these two(in terms of java)
In Procedural Abstraction, methods are used to capture the procedural patterns, abstracting over behaviour. For example, in Java, you could write something like:
public void printFibonacci(int n){
//your code to print Fibonacci numbers
}
In this way, users could use the procedure easily, without even having to wonder what's going on inside the function. You know that it will print the fibonacci for the given input.
On the other hand, in Data Abstraction, Classes are used to abstract the related stateful values and their associated behaviours -- also called a s Abstract Data Type (ADT).
For example, in Java, it consists of:
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments