What is the main difference between private and protected | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is the main difference between private and protected

what is the areas of access of aboves

26th Jan 2017, 7:52 AM
Sanjay Shah
Sanjay Shah - avatar
1 Answer
+ 11
Private objects/methods can only be accessed by the class itself, whereas protected objects/methods can be accessed by the class itself and its derived classes (via inheritance).
26th Jan 2017, 8:04 AM
Hatsy Rei
Hatsy Rei - avatar