+ 1
Can anyone tell me difference between Encapsulation and Abstraction?
8 Answers
+ 14
I will explain u with an example,
The class encapsulate every method in it that belong to it.
Encapsulation can be understood by capsule which contain the medicine in itself.
Abstraction is that the patient doesn't know about the medicine hidden in capsule. He just eat it as doctor says him.he had to no worry about the medicine inside the capsule.
Thus in java encapsulation help us to abstract the inner layer from the end user.
Hope it will make u understood.!!!
+ 4
Encapsulation is binding the attributes and methods together inside a class. It is obtained through OOP, where inside a class the methods along with the datatype lie together leading to a complete behaviour.
Abstraction on the other hand comes from the word abstract which deals with the user perspective. The user of the code need not know the internals or the working of your code and thereby should not have access to your variable which are essentially the properties of a class. It is achieved by using private, protected and public access specifiers. Generally, methods are kept public but member variable are kept private.
+ 3
encapsulation tend to make a interface, abstraction tend to make structure of concepts
+ 3
Encapsulation is about hiding the methods or inner workings of the object, while abstraction is about providing the user an interface where he uses inner methods without seeing them
+ 2
Encapsulation is way of accessing data without exposing it. You can use getters and setters to save and retrieve variables.
Abstraction makes the skeleton of the class if you make the function abstract, the subclass will have to override in their class.
+ 2
Encapsulation is the process of methods and properties into a single unit. Abstraction is used to achieve Encapsulation.
+ 2
encapsulation refers wrapping of data in single unit
example like we create function and then we call it main so all matter is wrap up in function.
abstraction refers to using essential feature without background details.
eg when we make no of function in a class and then when we want a function that we need so we just call it by creating it object and calling the particular function at this time we used the feature abstraction
0
yes in encapsulation we wrap up the whole data in one class or function i.e encapsulated
in abstraction we hide the unnecessary details from the user