Java Reference
In-Depth Information
15. Given the following Calendar class:
public class Calendar {
private static int FIRST_DAY = 1;
public static synchronized void setFirstDay(int value) {
FIRST_DAY = value;
}
public static int getFirstDay() {
return FIRST_DAY;
}
}
which of the following statements is true? (Select one)
A. The code does not compile.
B. Invoking setFirstDay generates an exception at runtime.
C. A thread that enters the setFirstDay method must own the lock of the Calendar's
Class object.
D. A thread that enters the setFirstDay method must own the lock of any instance of
Calendar.
E. The getFirstDay method must also be synchronized.
Search WWH ::




Custom Search