http://www.danchisholm.net/july21/topic/section1/class1.html Question 1
public class Basics {} // 1
class Basics1 {} // 2
protected class Basics2 {} // 3
private class Basics3 {} // 4
Class Basics4 {} // 5
Suppose these are top-level class declarations and not nested class declarations; and suppose that all of the declarations are contained in one file named Basics.java. Compile-time errors are generated at which lines?
a. 1
b. 2
c. 3
d. 4
e. 5
The answer given is:
1c d e 3 4 5 If a class C is declared as a member of an enclosing class then C may be declared using no access modifier or any of the three access modifiers, private, protected or public. However, if class C is not a local class, anonymous class or a member of an enclosing class or interface; then C may be declared with the public modifier or with package access (i.e. no modifier). The other two access modifiers, private and protected, are not applicable to any class that is not a member class. The class declaration, Class Basics4 {}, generates a compile-time error, because all of the letters of the reserved
word class must be lower case.
<<<<<< My verification>>>>>>>>>>>>>
when I have written the above class and compiled it compiled with out errors. Confused with the funda explained.
<<<<<<<<<<<<<<< ends here >>>>>>>>>>>>>>>>>>
Appreciate clarification.
Thanks