Java Programming - Declarations and Access Control - Discussion

Discussion Forum : Declarations and Access Control - General Questions (Q.No. 15)
15.
Which of the following class level (nonlocal) variable declarations will not compile?
protected int a;
transient int b = 3;
private synchronized int e;
volatile int d;
Answer: Option
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.

Discussion:
2 comments Page 1 of 1.

Guruputra said:   1 decade ago
How the transient can became access-specifier?
(1)

TINTU said:   1 decade ago
Synchronized modifier not only applied for method. It also applied for blocks.

Post your comments here:

Your comments will be displayed after verification.