JavaTip: Difference between Abstraction and Encapsulation in Java – OOPS

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.

Abstraction vs Encapsulation 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.

One thought on “JavaTip: Difference between Abstraction and Encapsulation in Java – OOPS

  1. Hello there, I discovered your web site via Google while searching for a comparable topic, your web site got here up, it seems
    to be good. I’ve bookmarked it in my google bookmarks.
    Hi there, simply changed into aware of your blog thru Google,
    and found that it is truly informative. I am gonna watch out for brussels.

    I will appreciate if you happen to proceed this in future.
    A lot of people will probably be benefited out of your writing.
    Cheers!

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s