Is it allowed to define a constructor for anonymous class?
-
Yes
-
No
-
In specific conditions
-
Not sure
B
Correct answer
Explanation
Java anonymous classes do not have a name, which prevents developers from declaring constructors, since a constructor must share the name of its declaring class. Instead, custom initialization is achieved using instance initializers or by passing parameters to the superclass constructor, so defining a constructor is not allowed.