0
Difference between private variable and protected variable?
5 Answers
+ 3
Private variables can't be accessed from outside the class. Protected variables are the same as private but with one exception that they can be accessed from derived classes
+ 2
Quoi Runtime yeah you're right. They make difference when you access the class outside the package(which is mostly you'll prefer when building large projects). Default access modifier acts as private outside the package. Protected acts like protected outside the package. Inside the package, both act the same like public access modifier.
+ 2
Quoi Runtime ;-)
+ 1
Rishi So what exactly is the difference between default and protected access modifiers? They all seem to be accessible within the same package.
+ 1
Rishi I better try this out in Eclipse. Thank you!