Computer Science, asked by ayan7456, 1 year ago

what is the differences between abstraction and encapsulation.

Answers

Answered by tejasgupta
2

  Abstraction means representing an object/class in relation to what it does to clients or outside world.  So the methods or functions which are public ie., the public interface is what is important here.  The implementation details of how the functions are achieved is hidden from the client.  Abstraction can be done at multiple levels - classes, sub classes etc..  There is no reference to the state of the objects here.

   Encapsulation refers to the state of the object.  means putting together the state (property) of the object along with methods to access the state.  This can be done with different ways of access modifiers ie., public, private and protected.  Essentially, the state of the object is hidden from the outside view of the object by encapsulation.  There is data access security here.  Encapsulation refers to implementation of the class and its interface.

   Encapsulation comes after the abstraction process is first done.  Encapsulation is part of abstraction process. 

Similar questions