aspose file tools*
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
JavaRanch » Java Forums » Certification » Mock Exam Errata
Bookmark "can a class be static ?" Watch "can a class be static ?" New topic
Author

can a class be static ?

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
This came from http://www.lanw.com/java/discover/default.htm :
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")
<pre>
keywords | classes | method | variables
static | a | b | c
final | d | e | f
protected | g | h | i
</pre>

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".
Thanks!!!
[This message has been edited by Emerald HA (edited April 26, 2001).]
Kishore Pamu
Ranch Hand

Joined: Mar 18, 2001
Posts: 35
Hi!Emerald,
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!

Kishore
Anonymous
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).]
 
wood burning stoves
 
subject: can a class be static ?