Multiple choice technology programming languages

Can inner classes have static members?

  1. Yes

  2. No

  3. In specific conditions

  4. Not sure

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

In Java, inner classes are non-static nested classes associated with an instance of the outer class. Consequently, they cannot declare static members (such as static methods or fields) unless they are compile-time constant fields (static final primitives/Strings). Hence, the general answer is no.