This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
The moose likes Java in General and the fly likes Difference b/w Abstraction and Encapsulation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Difference b/w Abstraction and Encapsulation" Watch "Difference b/w Abstraction and Encapsulation" New topic

Difference b/w Abstraction and Encapsulation

Senthil KumarR

Joined: Mar 09, 2009
Posts: 5
Hi All,

We all know basic OO concepts are:
1) Abstraction
2) Encapsulation
3) Inheritance
4) Polymorphism

I need to know the difference or the concept of Abstraction and Encapsulation.

They seem to be very confusion.

Please help.

Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

Abstraction is to hide/reduce implementation detail. The use of an interface is an example.
You know how to use it but you don't know the implementation details. Another example is
the iterator pattern. With that pattern you can hide the data-structure without compromising
it's accessibility.

Encapsulation is the process in which internal variables are hidden and made accessible by
certain methods.

"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Senthil KumarR

Joined: Mar 09, 2009
Posts: 5
Thanks Wouter...
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: Difference b/w Abstraction and Encapsulation
It's not a secret anymore!