Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

can a class be static ?

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic