What is encapsulation in python how to achieve it. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What is encapsulation in python how to achieve it.

pls give me some examples

7th May 2017, 6:27 AM
Sriram Chowdary Mellamputi
Sriram Chowdary Mellamputi - avatar
3 Answers
- 1
abstraction mins hide your data... use for secure important data class Sample{ private int i =10; } now i is accessible only within class encapsulation mins enclosing data in class use function defunition in class otherwise declare it and then give defination in outside of class class Sample { public static void main(String args[]) { void show() { } void sayHi() { } } } /* example codes are in java */
7th May 2017, 1:13 PM
Mayur Chaudhari
Mayur Chaudhari - avatar
+ 1
thank you for your information. could you tell diff detween encapsulation and abstraction with examples pls.
7th May 2017, 7:54 AM
Sriram Chowdary Mellamputi
Sriram Chowdary Mellamputi - avatar
- 1
encapsulation mins wrapping of data in single class unit... python use class concept
7th May 2017, 6:43 AM
Mayur Chaudhari
Mayur Chaudhari - avatar