Difference between Abstraction & Encapsulation
Abstraction:Abstraction is simply separating the top level usefulness of a thing from the details of its implementation. Keeping the details away from the consumer of the object, so that the programmer is freed from worrying about details that aren't relevant to his assignment.
- Abstraction focuses on the outside view of an object (i.e. the interface)
- Abstraction solves the problem in the design side
- Abstraction in Java is achieved by using interface and abstract class in Java.
- One example of Abstraction is creating interface to denote common behavior without specifying any details about how that behavior works
- Abstraction is accomplished in java by using Interface. - Just giving the abstract information about what it can do without specifying the back ground details
- Information/Data hiding is accomplished in java by using Modifiers - By keeping the instance variables private or protected.
Encapsulation:
Encapsulation is simply combining the data members and functions into a single entity called an object.
- Encapsulation (information hiding) prevents clients from seeing it’s inside view, where the behavior of the abstraction is implemented.
- Encapsulation solves the problem in Implementation.
- Encapsulation is the deliverables of Abstraction. Encapsulation barely talks about grouping up your abstraction to suit the developer needs.
- Encapsulation is accomplished in java by using Class. - Keeping data and methods that accesses that data into a singe unit