Encapsulation

Encapsulation is a language construct that facilitates bundling of data with the methods operating on that data.

How it is different from Data Hiding?

Data Hiding: is a design principle to prevent certain aspects of a class being accessible to its clients.

Thus, Encapsulation (language construct) of Java, Data Hiding can be achieved. But encapsulation only facilitates but does not guarantee information hiding. For example, a class - RectangleUtils, will have all the information of Rectangle Class. All the operations on primitive operations on Rectangle needs to be encapsulated under Rectangle class to achieve the Information Hiding of Rectangle class.

So, Data Hiding is broad term (principle) which is somewhat facilitates by Encapsulation (language construct).

What is Difference between Abstraction & Encapsulation?

Both means to abstract the behavior, but abstraction concentrates more on "observable behavior", but encapsulation concentrates more on "hiding of implementation".

So it is not Abstraction vs Data Hiding, but Data Hiding via Abstraction.

References:

  1. http://en.wikipedia.org/wiki/Information_hiding

  2. http://en.wikipedia.org/wiki/Encapsulation_(object-oriented_programming)

  3. http://www.javaworld.com/jw-05-2001/jw-0518-encapsulation.html

  4. http://stackoverflow.com/a/8694874/231567