The title says it all, I am bit confused as I was asked a question that Information handling in term of OOP is abstraction or encapsulation? I opted for abstraction but still I am confused because in encapsulation we also hide the fields and in abstraction we hide the details. Any help in this regard
4 Answers
It may help if you think of encapsulation as one of the tools used to create abstraction. See the wikipedia entry for encapsulation here http://en.wikipedia.org/wiki/Encapsulation_(object-oriented_programming)

- 574
- 4
- 19
Abstraction
generally hides information, while Encapsulation
separates the changeable data from the unchanged one. In this way, Encapsulation
helps to achieve the Open Closed Principle
.

- 3,900
- 1
- 18
- 20
Here is a nice answer that I think it clears the confusion
Encapsulation has two faces; data abstraction and information hiding. Data abstraction is a type seen from the outside. Information hiding is a type seen from the inside.
- Abstraction focuses on the outside view of an object (i.e. the interface)
- Encapsulation (information hiding ) prevents clients from seeing its inside view, where the behavior of the abstraction is implemented
Encapsulation = Hiding the Complexities / information
Abstraction = A (somewhat) defined way to handle complexities, using encapsulation

- 1,134
- 8
- 16
-
Abstraction is handling complexities? it doesn't hide your low level details? – Mar 30 '14 at 09:51
-
You are right I edited my answer, I was actually talking about the larger scope of functionality, but its better this way – sallushan Mar 30 '14 at 09:57