CrazyEngineers
  • Hi Folks,

    Could anyone make me clear the difference between encapsulation and abstraction.
    In my POV the difference between Encapsulation and Abstraction is....
    Encapsulation : Encapsulation is the way of integration like object+dataMember into a single unit. Where the data is hidden...

    Abstraction : Hiding the implementation of the business logic...

    Need a good guidance over this topic.
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • Sanyam Khurana

    MemberSep 11, 2013

    Nikumbh
    Hi Folks,

    Could anyone make me clear the difference between encapsulation and abstraction.
    In my POV the difference between Encapsulation and Abstraction is....
    Encapsulation : Encapsulation is the way of integration like object+dataMember into a single unit. Where the data is hidden...

    Abstraction : Hiding the implementation of the business logic...

    Need a good guidance over this topic.

    See, Encapsulation is an OOP feature, when you bind all your data members and associated member functions, under a single unit.
    This is done through Class.

    Eg:
    class test
    {
    int a,
    char b[10];
    public:
    int check();
    }
    Here, a and b are data members, where as check is some method, so you have all this defined under a single unit, ie class here.
    This is encapsulation.

    Abstraction refers to data hiding, which is done through access levels namely private, public and protected for C++ , and for java there is private, protected, public and default levels.

    Sometimes, we want to give only essential details, without giving out all the background details.
    In the above example, class by default has a private access level, so the data members, a and b are kept private, where as the function is made public.

    These things sound more clear when you learn about inheritance.
    Are you sure? This action cannot be undone.
    Cancel
  • vikaskumar11233

    MemberSep 12, 2013

    Encapsulation means hiding unimportant data whereas Abstraction means wrapping up of data.
    Are you sure? This action cannot be undone.
    Cancel
  • Sanyam Khurana

    MemberSep 12, 2013

    vikaskumar11233
    Encapsulation means hiding unimportant data whereas Abstraction means wrapping up of data.
    Are you sure, about this..?

    vikaskumar11233
    Encapsulation means hiding unimportant data
    You have mix matched...
    And why would someone, hide UNIMPORTANT data..?
    Are you sure? This action cannot be undone.
    Cancel
  • Alok mishra

    MemberSep 12, 2013

    Encapsulation is about keeping things (data and code to manipulate that data) in a single unit called class . There are access specifiers (private, protected,public and default) that give encapsulation its importance .
    Abstraction is undoubtedly information hiding as most often we are concerned only about outcome not to the entire internal architecture.
    Like while driving car ,driver pushes the break and car stops he doesnt even bother what its internal mechanism was.
    More precisely abstraction is used to reduce complexity.
    Are you sure? This action cannot be undone.
    Cancel
  • Anoop Kumar

    MemberSep 12, 2013

    Do not confuse with Abstract keyword in java. that is something else.

    Abstraction: Car break, as a user you don't have to know about every detail of how break works. you just apply the break and that's it. Of-course if you want you can see and how they are being used.
    In programming terms API's are best example of abstraction. you just have to know how to call api. like api's for barcode reading, encryption etc.

    Encapsulation: Totally wrapped system like engine, binding all engine component into one unit. you may not have access to internal system to see what inside it, unless a car mechanic will open it and repair it.
    Are you sure? This action cannot be undone.
    Cancel
  • Nikumbh

    MemberSep 12, 2013

    So, can I take this as.....
    Abstraction : Is hiding the implementation of a class dataMember(most probably methods inside the class). ie., interface in java
    Encapsulation : Is apart from wrapping up object + datamember, hiding the data inside the dataMember. ie., encapsulation uses the data hiding concept.

    For example StringBuffer class in java. When we create an instance for StringBuffer.
    like,
    StringBuffer sampleString=new StringBuffer("My String");

    Here the abstracted information is

    * size of the sampleString. (Data hidden)

    sampleString.append("appended String 2");

    Now the StringBuffer pointer moved to the end of the "My String" with the help of size of the sampleString's last index and start appending the new string.
    correct me if i'm wrong.
    Are you sure? This action cannot be undone.
    Cancel
  • Anoop Kumar

    MemberSep 12, 2013

    encapsulation is binding things together and preventing from unauthorized access.

    Yes, for your example abstraction looks good.
    Are you sure? This action cannot be undone.
    Cancel
  • Nikumbh

    MemberSep 15, 2013

    @#-Link-Snipped-# : The example what I explained above is for data hiding. Encapsulation rather does data hiding over the implementation part from interface, apart from encapsulating the interface with the implementation.

    There are two mechanism to conduct ABSTRACTION.

    1.Encapsulation
    2.Polymorphism


    correct me if i'm wrong.
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register