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

This is nonsense. Your definition of abstraction and encapsulation are the same.
ReplyDeleteHow come definition is same, Its clearly saying that abstraction is implemented using interface and abstract class and Encapsulation is implemented using private keyword and other access modifier.
Deleteneed more clear concept about abstraction...
ReplyDeleteexamples explaining both concepts would be helpful.
ReplyDeleteWell Abstraction and encapsulation are both viewing same thing in java with different point. here abstarction means showing functionality hiding information i.e complexity and in encapsulation u do same thing u wrap up things within a class which will encapsulates. wat i can say is abstraction is evalved from encapsulation by its implementation and abstraction by its use. i.e encapsulation is part of abstraction. Ex: creating a class is encapsulation and way of implementation i.e by using intereface and abstract classes is abstraction.
ReplyDelete