I asked because its not C++,where a class doesn't have a access specifier.As Java added this feature,so my question is valid.
Joined: Jan 24, 2006
I never said your question wasn't valid, all I asked is why you would want a 'CLASS' protected? I don't think you would want to make a class all in itself protected, but maybe and instance of that class in another class.
Justin [ June 27, 2008: Message edited by: Justin Fox ]
Joined: Jun 27, 2008
It's not that i want.I am just curious to know about this feature of Java.Also, i am a bit surprised that a protected member can be accessed in a non sub-class,unlike C++.
The possible access modifiers for any top level class are either public or no modifier (package). Apart from this you can make the class abstract or final depending on the need. One of the reason could be they do not serve any purpose
Protected and private are very much acceptable modifiers, but they are applicable to inner classes.
Unline in C++, java inhenritance is always public. There is no mechanism to specify the modifier during inheritance the way you do it in C++.