Can anyone please explain private, public and protected in classes and objects?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Can anyone please explain private, public and protected in classes and objects??

classes and objects

14th Mar 2018, 2:19 PM
Thomas Kurian
Thomas Kurian - avatar
2 Answers
+ 4
thanks a lot with pleasure@ Jonathan Carver.😊. hope you will help me whenever I need it.
22nd Mar 2018, 2:08 PM
Thomas Kurian
Thomas Kurian - avatar
+ 3
Private (or class-private) restricts the access to the class itself. Only methods that are part of the same class can access private members. Protected (or class-protected) allows the class itself and all its subclasses to access the member. Public means that any code can access the member by its name. Reference: wikipedia
14th Mar 2018, 2:42 PM
Dread
Dread - avatar