well , i just read a chapter of inner class from K&B cirtification book and i think the answer is : there is no difference b/w inner class & nested class but if we mark inner class as a static then it would be called as a top level nested class it would not be technically an inner class .
is the answer is correct ??? Well from what you just wrote there
is a difference, technically, so I'm not sure what you mean.
Note that the egregiously silly term "top-level nested class" was removed from Sun's terminology several years ago when JLS second edition came out. (Unfortunately not everyone realized this right away, including K & B.) The terms "top-level" and "nested" are mutually exclusive. All classes are either top-level or nested (not both). All nested classes are either static nested classes (also known as static member classes), or inner classes (any nested class that's not static). Inner classes are either non-static member classes, local classes, or anonymous classes.
Why knowing this distinction (rather than, say, understanding the access difference between a static and non-static inner class) has any bearing on being able to engineer software using Java is the really hard question... Well, if you ever consult the
Java Language Specification, it's very helpful to have a correct understanding of the terms as the JSL defines them and uses them. The JLS uses terminology very precisely, and programmers need to do so as well in order to understand it correctly.
Having said that, I think the original question makes a rather poor interview question, because many otherwise excellent programmers would answer incorrectly due to the large amount of contradictory information which can be found in Java books. Sun made a mess of this by not using their terminology consistently when they first introduced nested classes (not in the JLS - it was a document known both as the Inner Classes Specification, and the Nested Classes Specification, which indicates the basic problem). They've cleaned up their mess since then, mostly, but there are still many people who learned different terminology.
[ January 12, 2005: Message edited by: Jim Yingst ]