Java OCA OCP Practice Question 1826

Question

Which of these field declarations are legal within the body of an interface?.

Select the three correct answers.

  • (a) public static int answer = 42;
  • (b) int answer;
  • (c) final static int answer = 42;
  • (d) public int answer = 42;
  • (e) private final static int answer = 42;


(a), (c), and (d)

Note

Fields in interfaces declare named constants, and are always public, static, and final.

None of these modifiers are mandatory in a constant declaration.

All named constants must be explicitly initialized in the declaration.




PreviousNext

Related