The following paragraph is taken from Java OCP 8 Programmer II Study Guide (Sybex Ch 1 - p30) from Jeanne boyarsky
"But what if we want to implement both an interface and extend a class? You can’t with an anonymous inner class, unless the class to extend is java.lang.Object. Object is a special class, so it doesn’t count in the rule."
Q. How can we both implement an interface and extend a class from java.lang.Object? How does not Object class count in the rule? Please explain through example.
. . . The superclass or superinterface of an anonymous class is given by the class instance creation expression . . .
So what is that class' immediate supertype? Is it Foo or Bar? If you write extends in an anonymous class declaration, you are risking giving the class two superclasses, and as you know, two superclasses are not permissible. extends
Story like this gets better after being told a few times. Or maybe it's just a tiny ad:
create, convert, edit or print DOC and DOCX in Java