Multiple choice technology programming languages

What is the rule of anonymous class

  1. Can have only one constructor

  2. a.Cannot have a constructor

  3. Can have more than one constructor

  4. May or May not have constructors

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

Anonymous classes in Java cannot have explicitly declared constructors. They can only use the implicit no-arg constructor (if extending a class) or must match a constructor signature from the parent class/interface. This is because anonymous classes have no named class definition to declare constructors for.