aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes A question about anonymous inner class? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "A question about anonymous inner class?" Watch "A question about anonymous inner class?" New topic
Author

A question about anonymous inner class?

roger moon
Greenhorn

Joined: May 13, 2005
Posts: 8
Would anyone shed some light on the answer D? Why is it right? I learned
from a book that "an anonymous inner class can't even extend a class and
implement an interface that the same time".

which two are true? Answer: A, D
A. An anonymous inner class can be declared inside of a method.
B. An anonymous inner class constructor can take arguments in some situations.
C. An anonymous inner class that is a direct subclass of Object can implements multiple interface.
D. Even if a class Super does not implement any interfaces, it is still possible to define an anonymous inner class that is an immediate subclass of Super that implements a single interface.
E. Even if a class Super does not implement any interfaces, it is still possible to define an anonymous inner class that is an immediate subclass of Super that implements multipe interface.
Tony Morris
Ranch Hand

Joined: Sep 24, 2003
Posts: 1608

I learned from a book that "an anonymous inner class can't even extend a class and
implement an interface that the same time".

You're right, it can't. But it can do one or the other. An anonymous class can subtype a concrete type (a class) or an interface, but not both.


Tony Morris
Java Q&A (FAQ, Trivia)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: A question about anonymous inner class?