if protected is accessible by all the classes inside a same package and outside of the package too then what is the difference it does when compared to public?... | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

if protected is accessible by all the classes inside a same package and outside of the package too then what is the difference it does when compared to public?...

15th Aug 2016, 6:39 AM
Gowtham krvz kv
Gowtham krvz kv - avatar
3 Answers
+ 4
you can access superclasses protected members which are not a part of same package whereas you won't be able to go beyond package level with default access modifier.
15th Aug 2016, 7:24 AM
Abhishek C Prajapati
Abhishek C Prajapati - avatar
+ 1
out of package it's accessible to Inherited classes .
21st Aug 2016, 7:45 PM
sana shah
sana shah - avatar
0
in protected access modifier we can not access classes of another packages...but in public there is no restriction.
15th Aug 2016, 6:46 AM
AKSHAY MALVIYA
AKSHAY MALVIYA - avatar