Can any one tell the correct answer for the following question and explain why?
Q: Which of the following are true about the class defined inside an interface ANS: 1).it is not possible in the java Language. 2).The class is always public. 3).The class is always static. 4).the class methods cannot call the methods declared in the interface. 5).the class methods can call only the static methods declared in the interface.
1) It is possible, 2) It is allways public because an interface by default makes all members public even when a modifier isn't specified. 3) This class is allways static but I'm not sure of the reason why, it could be that interfaces don't have any "this" pointer thus making it impossible for an inner class to reference i 4) It can call the methods as long as the inner class method has a reference to an object which implements the outer interface. 5) False, it can call any method in the interface, a static inner class means that an instance of the inner class has by default no relationship to an instanceof the outer class. Infact a non-static inner class CANNOT be created unless the outer class is created first.
4- true, there are no methods in an interface, only prototypes of methods. Of course, if the inner class implemented the interface, then it would have to define a method body for all method prototypes of the interface, which could be called by another method of the inner class. But then, it would be a method of the inner class being called, not a method of the interface 5- false, interfaces may not have static method prototypes, hence, there's nothing to call.