What is static and a non-static inner class?

Answers were Sorted based on User's Feedback



What is static and a non-static inner class?..

Answer / guest

Non Static inner classes have object instances that are
associated with the classes outer class.Static inner
classes have no object instances.

Is This Answer Correct ?    3 Yes 1 No

What is static and a non-static inner class?..

Answer / karthee

Static inner class
can only access the static members of the enclosing class.
not associated with the instance of the enclosing class.
can only have static members.

Nonstatic class
is associated with the instance of the enclosing class.(we
need it first to access the nonstatic class)
can access all the member of the encosing class.
is like other members of the enclosing class.

Is This Answer Correct ?    2 Yes 0 No

What is static and a non-static inner class?..

Answer / p.nandakishore

non static inner classes can access all the members of the
outer class i.e both static and nonstatic members.In
nonstatic inner classes we cannot have static declarations
done.To access non static inner class members we outer
class reference.

static inner classes can access only static members of the
outer class.In static inner class we can have static
declarations done. To access static inner class members
no need of outer class reference.

Is This Answer Correct ?    0 Yes 1 No

Post New Answer

More Core Java Interview Questions

what is the difference between yielding and sleeping? : Java thread

0 Answers  


i would like to attend for an interview of datalab technologies company i want to know the pattern of imnterview.

0 Answers  


Why is it called a string?

0 Answers  


How can you make a class serializable in java?

0 Answers  


Explain the different forms of polymorphism?

0 Answers  






What do you understand by synchronization?

0 Answers  


How large is a boolean?

0 Answers  


How to call static method?

4 Answers   Epoch,


What language is java written?

0 Answers  


Can we declare main () method as non static?

0 Answers  


Where local and global variables are stored?

0 Answers  


Explain inner classes ?

0 Answers  


Categories