Home » Java Programming » Language Fundamentals

Which three piece of codes are equivalent to line 3? final int k = 4; public int k = 4; static int k = 4; abstract int k = 4; volatile int k = 4; protected int k = 4; public interface Foo { int k = 4; /* Line 3 */ }

Correct Answer: 1, 2 and 3

Explanation:

(1), (2) and (3) are correct. Interfaces can have constants, which are always implicitly public, static, and final. Interface constant declarations of public, static, and final are optional in any combination.
Next Question→

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion