It's not a secret anymore!*
The moose likes Mock Exam Errata and the fly likes can a class be static ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Mock Exam Errata
Bookmark "can a class be static ?" Watch "can a class be static ?" New topic

can a class be static ?

Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
This came from :
For each Java keyword in the left column, check the categories which it can be used as a modifier. (For instance you can declare a "final static method")
keywords | classes | method | variables
static | a | b | c
final | d | e | f
protected | g | h | i

My answers are - a, b, c, d, e, f, h, i - thinking class includes inner classes, and there can be static inner classes.
Would anybody say otherwise? Please explain, as the correct answers are only - b, c, d, e, f, h, i - Comment for 'a' is "No, although you can have a class with only static methods and variables".
[This message has been edited by Emerald HA (edited April 26, 2001).]
Kishore Pamu
Ranch Hand

Joined: Mar 18, 2001
Posts: 35
A toplevel class can be declared public or default(i.e no access modifier).
private,protected and static cannot be declared to toplevel class
Only the inner classes can be declared static ,private,default(i.e no access modifier),protected,public.
hope this helps!

Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Thanks Kish.
I guess this is a matter of how the question should be interpreted. Does 'classes' per se, as given in the question, just mean top-level class and excludes nested classes?
- Emerald -

[This message has been edited by Emerald HA (edited April 27, 2001).]
I agree. Here's the link:
subject: can a class be static ?
Similar Threads
Why must non-static inner classes declare static fields final?
Modifiers for inner classes
any difference between inner class and nested class?
Output from outer/inner class code?
few questions(topics mixed)