Programming - Inner Classes - Discussion

You Are Here :: Home > JAVA > Inner Classes - Discussion

 



Q.

Which is true about an anonymous inner class?                         


A. It can extend exactly one class and can implement multiple interfaces. B. It can extend exactly one class and implement exactly one interface.
C. It can extend exactly one class or implement exactly one interface. D. It can implement multiple interfaces regardless of whether it also extends a class.

Answer: Option C
Explaination:

 


because the syntax of an anonymous inner class allows for only one named type after the new, and that type must be either a single interface (in which case the anonymous class implements that one interface) or a single class (in which case the anonymous class extends that one class).




Discussion

Your Comments Goes here...
NameDiscussion