Top

Discussion

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

  • A.protected int a;
  • B.
    transient int b = 3;
  • C.private synchronized int e;
  • D.volatile int d;

Answer: C

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.

No comment is present. Be the first to comment.
Loading…

Post your comment