MCQ Single Best Answer Not Set

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

ID: #1986 Java Language Fundamental 2,491 views
Question Info
#1986Q ID
Not SetDifficulty
Java Language FundamentalTopic

Choose the Best Option

Click any option to instantly check if you're correct.

  • A 1, 2 and 3
  • B 2, 3 and 4
  • C 3, 4 and 5
  • D 4, 5 and 6
Correct Answer: Option A

Explanation

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

Share This Question

Challenge a friend or share with your study group.