ProgrammingHardGATE CS · TCS NQT Prime · Product Company SDE

What access modifier and finality does a field declared directly inside a Java interface implicitly have?

  1. A. private final
  2. B. public, and mutable by any implementing class
  3. C. protected static
  4. D. public static final

Correct answer: D. public static final

Fields in an interface are always implicitly public, static and final, i.e. shared constants, whether or not those keywords are written explicitly.

More OOP with C++ and Java questions

Exams that ask this topic