title: Abstraction vs Encapsulation in Java
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/24626/abstraction-vs-information-hiding-vs-encapsulation">Abstraction VS Information Hiding VS Encapsulation</a>  </p>
  </blockquote>
  
  
  
  <p>I know this question might have been asked thousands times on this forum, even net is also filled with lots of definitions about these concepts but all sounds same and all uses same technical words. For example following definitions</p>
  
  <p><strong>Encapsulation</strong> is a process of binding or wrapping the data and the codes that operates on the data into a single entity. This keeps the data safe from outside interface and misuse. One way to think about encapsulation is as a protective wrapper that prevents code and data from being arbitrarily accessed by other code defined outside the wrapper.</p>
  
  <p>What I understood from above definition is that creating variables, mark them private and generate getter-setter for those variables and use object to access those getter and setter. In that way data is hidden inside object and is only accessible through object. <strong>Hope I am right</strong>.</p>
  
  <hr>
  
  <p><strong>Abstraction</strong> is the process in Java which is used to hide certain details and only show the essential features of the object. In other words, it deals with the outside view of an object (interface). </p>
  
  <p>Now this is the part which confuses me always. Whenever I think about abstraction the thing which comes to my mind is Abstract class(may be because both have Abstract keyword). Above definition says abstraction means hiding data and only showing required details but that is what we are already doing in encapsulation right? then what is the difference. Also I did not get what is out side view of object in <strong>it deals with the outside view of an object</strong>.</p>
  
  <p>Can someone please put more light on this with some real life example or with some programmatic examples if possible. </p>