-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path25.6_Abstraction & Encapsulation.py
30 lines (15 loc) · 1.43 KB
/
25.6_Abstraction & Encapsulation.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#Abstraction & Encapsulation :-
'''
1). What is Abstraction ?
Abstraction refers to hiding unnecessary details to focus on the whole product instead of parts of the project separately.
It is a mechanism that represents the important features without including implementation details. Abstraction helps us in partitioning the program into many independent concepts so we may hide the irrelevant information in the code. It offers the greatest flexibility when using abstract data-type objects in different situations.
In programming, abstraction cannot be achieved without Encapsulation.
Example :- A car which has hidden parts such as camshaft, valves, etc.
2. What is Encapsulation ?
Encapsulation means hiding under layers. When working with classes and handling sensitive data, global access to all the variables used in the program is not secure. In Encapsulation, the internal representation of an object is generally hidden from the outside to secure the data.
Example :- Capsule.
3. To sum it up :-
Abstraction and Encapsulation are fundamental concepts of OOP.
Encapsulation takes all the worry away from the user, providing him with just the product that he requires, irrespective of the way it is formed.
Abstraction focuses on the working of the object instead of the how part, while Encapsulation is all about hiding the way or method of working and just providing the working model.
'''