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.