Multiple choice technology programming languages

  1. Can an Interface have an inner class?

  1. True

  2. False

Reveal answer Fill a bubble to check yourself
B Correct answer
AI explanation

Strictly, the answer is False: an interface cannot have an 'inner class.' You CAN declare a class inside an interface and it compiles, but per the Java Language Specification any member type declared in an interface is implicitly public and static (JLS 9.5). The JLS defines an inner class as 'a nested class that is not explicitly or implicitly declared static' (JLS 8.1.3). Because a class nested in an interface is always static, it is a static nested class, never an inner class. Therefore, under correct Java terminology, an interface can host nested (static) classes but not inner classes — the marked answer False is correct. The confusion arises only when 'inner' is used loosely to mean 'nested,' which is imprecise.