posted 24 years ago
Well I don't know what JQ+ said, but you have asked about 12 questions here. Are we talking methods, fields or classes access modifiers? And are we talking methods and fields in a class or in an interface?
Let's try and sort this out.
*****************************************
For top level classes, which can only be public or default, either is fine with abstract. Volatile and Synchronized do not apply to the class declaration itself. Inner classes can be abstract and can have any access modifier.
Every interface is implicitly abstract. This modifier is obsolete and should not be used in new programs
For interfaces, access modifiers protected and private pertain only to member interfaces within a directly enclosing class declaration. (Inner Interfaces)
**************
For methods that are synchronized you can use any access specifier, in fact the JLS has several examples of public synchronized methods.
For methods that are abstract you can use any access modifier except private.
A compile-time error occurs if a method declaration that contains the keyword abstract also contains any one of the keywords private, static, final, native, strictfp, or synchronized.
For methods in an interface, which are implicitely public and abstract it is "permitted by discouraged" to redundantly use the keywords public and abstract.
Volatile does not apply to methods.
********
For fields which are volatile, they can have any access modifier.
Fields are never abstract. Fields are never synchronized.
Gee I think that covers it.
"JavaRanch, where the deer and the Certified play" - David O'Meara