Originally posted by ramya jp:
[QB]A class inside an interface is always public and static and cannot call the methods declared in the interface...compiles without an error,even though the inner class A is abstract.QB]
True. The class inside an interface is always public and static. To prove that it's public, try compiling it with a "private" qualifier. The compiler will tell you that it has to be "public".
To prove it's static (the dreaded static nested class), compile it with the static keyword, and run javap A on it. Look at the results. Then compile it without the static keyword. run javap A on it. Compare the results. It's the same bytecode!!!
To answer your question why your example compiles correctly, you've shown an example of a nested class in an interface. The compiler compiles it as a static and public class. Your class just happened to be an abstract class. It's still public and static. It just happens to be abstract.
If you want to write some code that proves the third point, write (something) like this [I don't have a compiler handy]
In this example I'm trying to call a method in the interface from a static nested class. Compiler won't allow it.
Any class you create in an interface (whether it's an abstract class or a fully implemented class) is a static nested class. Static nested classes can't access any instance methods nor variables from their "enclosing" classes.
I hope that clears that up. Furthermore K+B don't cover classes inside interfaces in their book, that should give you some idea of how relevant it is for the exam (hint: it's not, imho!).