It allows you to use a class and override a method in a specific case where the usage is isolated and/or relies on access to local variables.
Whether it is easier or not is somewhat subject and down to personal taste. However it means everything is in situé in your code which enables you to understand what is happening without having to browse to another file or another location in your file. In simple cases, like the above, that is generally easier to work with than having to jump around your codebase.
For local
to be accessible it would need to be declared final
.
To answer your questions specifically:
- No; it is anonymously extending another class, thus equivalent to defining a class that extends another, so the same rules apply. You must override any abstract methods.
- It is more readable because it is all in the same location as the code that requires it.
- Yes, any interface or class.