So, "protected" encapsulation mode is less restrictive than "private", isn't it? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

So, "protected" encapsulation mode is less restrictive than "private", isn't it?

1st Aug 2016, 7:04 AM
Aidar Sadykov
Aidar Sadykov - avatar
2 Answers
0
Protected only lets the current class and inherited classes to use it.
1st Aug 2016, 11:36 AM
Andreas BeEm Kvist
Andreas BeEm Kvist - avatar
0
private allows the variable/function to be accessed only in the particular block of the program however protected allows the variable/function to be accessed in the current and inherited classes.
15th Dec 2016, 5:19 PM
Vidhi Tiwari
Vidhi Tiwari - avatar