Abstraction is a process where you show only
“relevant” data and “hide” unnecessary details of an object from the user.
Consider your mobile phone, you just need to know what buttons are to be
pressed to send a message or make a call, What happens when you press a button,
how your messages are sent, how your calls are connected is all abstracted away
from the user.
Abstraction is the process of hiding the details of a
particular concept from a user and exposing only required features.
Advantages of Abstraction:
1.
Managing complexity of code
2.
Decomposing Complex system into smaller
components.
Encapsulation is the process of combining data
and functions into a single unit called class. In Encapsulation, the data is
not accessed directly; it is accessed through the functions present inside the
class. In simpler words, attributes of the class are kept private and public
getter and setter methods are provided to manipulate these attributes. Thus,
encapsulation makes the concept of data hiding possible.
Encapsulation is the process of hiding the irrelevant
information and showing only the relevant information of a specific object to
user.
Advantage of Encapsulation:
1.
It provides way to protect data from
unauthorized access. For this we define the fields as private
2.
Increases maintainability of code by showing
relevant data
3.
Binds member functions and variables into single
unit.
0 Comments