Abstraction vs Encapsulation – Java OOPS
Abstraction and Encapsulation in Java are two important Object oriented programming concept and they are completely different to each other. Only similarity between Abstraction and Encapsulation is that they are OOPS concept, other than that they mean two different things. Abstraction represent taking out the behavior from How exactly its implemented, one example of abstraction in Java is interface while Encapsulation means hiding details of implementation from outside world so that when things change no body gets affected. One example of Encapsulation in Java is private methods; clients don't care about it, You can change, amend or even remove that method if that method is not encapsulated and it were public all your clients would have been affected. Apart from this main difference in behavior here are couple of more differences between Abstraction and Encapsulation in Java.
Abstraction vs Encapsulation in Java
Here are some of the main differences between Abstraction vs Encapsulation in Java and OOPS(Object Oriented programming) concept. Abstraction and Encapsulation along with Inheritance and polymorphism forms basis of Object oriented programming in Java.
1) First difference between Abstraction and Encapsulation is that, Abstraction is implemented in Java using interface and abstract class while Encapsulation is implemented using private, package-private and protected access modifier.
2) Encapsulation is also called data hiding.
3) Design principles "programming for interface than implementation" is based on abstraction and "encapsulate whatever changes" is based upon Encapsulation.
That's all from my side on differences between Abstraction and Encapsulation in Java. Correct understanding of Encapsulation and Abstraction is must for any Java developer. Head first Object oriented Analysis and design is a great book to learn more about Abstraction, Encapsulation and other OOPS concept.
Other Java programming and OOPS tutorials