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

How to prevent to create multiple objects of a java class?

3 Answers   ASD Lab, TCS,


Why string is called as immutable?

0 Answers  


What is deserialization and how do we do deserialization?

3 Answers   Synechron,


What is the use of callablestatement?

0 Answers  


What are the two ways of implementing multi-threading in java?

1 Answers  






What is difference overloading and overriding?

0 Answers   Cyient,


________ exception must be either caught or specified in throws class of the method.

1 Answers  


What will happen inside init() in servlet. my interviewer asked servlet lifecycle. i said "once servlet is loaded in to memory init() will be called which performs servlet initialization " . Again interview asked what values will be initialized . what is difference between init() and init(ServletConfig config).

2 Answers   Infinite Computer Solutions, TCS,


What is a void return type?

6 Answers  


What is meant by javabeans?

0 Answers  


How are the elements of a gridbaglayout organized?

0 Answers  


Can we make constructors static?

0 Answers  


Categories