Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Difference b/w Abstraction and Encapsulation

 
Senthil KumarR
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Thanks
 
Wouter Oet
Saloon Keeper
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Senthil KumarR
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Wouter...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic