Object Oriented Applications: Data Abstraction in Java

In the field of computer programming, abstraction refers to the process of defining programs and data with a representation that retains its similarity with the meaning but ensuring to hide all the implementation data. Abstraction exists in two different ways. One of them is data abstraction. Data abstraction refers to the way of creating relatively complex data types while ensuring only to expose the significantly meaningful operations: helps in hiding away all the other implementation details from the external works (Carrano, 2007).

In Java, the concept of data abstraction is useful in quite a number of ways. First, it allows the programmer to hide the complexity of his work quickly while efficiently achieving the desired functionality. Through the use of data abstraction, a programmer can easily separate all the things that easily fit optimally in various data types. Specifically, all the methods and properties that exhibit a relatively high level of changing frequency can be arranged separately in a way that there exists a primary data type that does not require many changes. It is practically important especially as far as the OOAD principle of “ensuring that code is open for extension in as much as it is closed for modification” stands (Reddy, 2012).

For example, to make a class contain a given method but with the actual implementation of that particular method being determined by some child classes, one should declare the method in the parent class as abstract.  An abstract method will have no definition and rather than curly braces, a semicolon follows its signature as illustrated by the code below:

public abstract class Workers


private String name;

private String contact;

private int id;


public abstract double computeDues();


//More info to definition of class



For a method to be abstract, the class must be declared as abstract as well. More so, every child class must be abstract itself, or it must override the fundamental theoretical method. Finally, the descendant classes must implement the abstract method without which there would be various levels of abstract classes impossible to instantiate. In the example above, if Wages extends Workers class, it should implement the computeDues as indicated below:

/* File name : Wages.java */

public class Wages extends Workers

{   private double wages; // Weekly Wages

public double computeDues()


System.out.println(“Calculating Wage Dues for ” + getName());

return salary/52;   }

//More info to definition of class



Carrano, F. M. (2007). Data Structures and Abstractions with Java. London: Prentice Hall.

Reddy, S. (2012, June 4). Abstraction in Object Oriented Programming. Retrieved March 31, 2015, from Java9s.com: http://java9s.com/core-java/abstraction-in-object-oriented-programming


Before you go, you are invited to support a noble cause on IndieGoGo:
HTML Snippets Powered By : XYZScripts.com