Multiple choice

Which of the following class level (nonlocal) variable declarations will not compile?

  1. protected int a;

  2. transient int b = 3;

  3. private synchronized int e;

  4. volatile int d;

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

Option C will not compile; the synchronized modifier applies only to methods. Option A and B will compile because protected and transient are legal variable modifiers. Option D will compile because volatile is a proper variable modifier.