Computer Science, asked by hea9vyac6hin, 1 year ago

difference between encapsulation and abstraction in java

Answers

Answered by Anonymous
1

Encapsulation is a mechanism by which you restrict the access to some of the object's components, as well as binding the data and methods operating on the data. 

Now if we consider a laptop, as an end user I have access only to some features of the  system. So I could use the mouse to move the cursor, or the keyboard for typing text, but I would not have access to the internal components of the laptop. Again the keyboard in turn is bound internally to a set of methods that operate in response to a user action or an event.

Abstraction is the ability to define an object that can represent abstract entities which can work, change state and communicate with other entities.
Answered by neerjabinu
0
Encapsulation is a process of binding or wrapping the data and the codes that operates on the data into a single entity. This keeps the data safe from outside interface and misuse. 
What I understood  is that creating variables, marking  them private and generating  getter-setter for those variables and using object to access those getter and setter. In that way data is hidden inside  and is only accessible through object.

Abstraction is about identifying commonalities and reducing features that you have to work with at different levels of your code.
Similar questions