Declarations and Access Control

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

A private synchronized int e;

B transient int b = 3;

C volatile int d;

D protected int a;

ANS:C - private synchronized int e;

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.

img not found

For help Students Orientation
Mcqs Questions

One stop destination for examination, preparation, recruitment, and more. Specially designed online test to solve all your preparation worries. Go wherever you want to and practice whenever you want, using the online test platform.