Saturday, April 09, 2011

Can a Class (Inner or Outer) be declared static ?

- Short answer –

Yes

- for the impatient but wana know more kind –

only Nested-Top level class can be declared static.

There are 2 types of class Top-level (Opter) and Inner (Anonymous, Local,Member,Nested top-level)

Local – Class declared in a code block or method and is visible inside tha block only like a local variable

Member – is visible for the entire class, you can instantiate this class only with in the context of the object, and hence cannot have its own indivudial existance, and cannot be instantited without an object of the outer class

Nested top level class – is like a member class with static modifier. It is just like anyother top-level class but declaed inside another class,

long answer starts here - :)

No comments: