What is recommended private or protected | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What is recommended private or protected

I see a contradiction between encapsulation and inheritance, what do you think?

10th Apr 2017, 4:08 AM
Andres Restrepo
Andres Restrepo - avatar
5 Answers
+ 7
depends on requirements
10th Apr 2017, 6:46 AM
Tarique Khan
Tarique Khan - avatar
+ 1
You will be better with practice. I don't see any contradiction. It is easier when you have UML diagrams. You see contradiction on a virtual level which is probably your Brain's representation of these concepts but in fact they are program and program can handle parallel tasks better than humans.
10th Apr 2017, 4:17 AM
Ravindra Sisodia
Ravindra Sisodia - avatar
+ 1
Nop no contradiction, in general use private for attributes and implement get and set methods public or protected, depend you want
10th Apr 2017, 9:19 AM
nextco
nextco - avatar
+ 1
Virtually there's no contradiction
11th Apr 2017, 11:37 AM
Akintolu Wasiu
Akintolu Wasiu - avatar
0
its depends
21st Jun 2017, 11:13 AM
SHIVA GOPI
SHIVA GOPI - avatar