Welcome Guest | Sign in | Register
Inner Classes - Discussion Page For Q.3019 | Java Programming Questions and Answers | Java Programming Free Online-Tests | LucentBlackBoard | LucentBlackBoard.com

Home > Java Programming > Inner Classes > Questions and Answers

Q: Which is true about an anonymous inner class?
A. It can extend exactly one class and implement exactly one interface. B. It can extend exactly one class and can implement multiple interfaces.
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 and Explanation

Answer:It can extend exactly one class or implement exactly one interface.

Explanation:
Option C is correct 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).
Option A, B, D, and E are all incorrect because they don't follow the syntax rules described in the response for answer Option C.

Comment on this Question

Name:

Loading...




Partner Sites
LucentBlackBoard.com                  SoftLucent.com                  LucentJobs.com
All rights reserved © 2012-2015 SoftLucent.