97. 3. Given:
Which statement is true?
A. The code prints "Bye".
B. The code will never wakeup unless you press Crtl+C
keys.
C. The code will not compile unless replace Thread.sleep
with Thread.currentThread().sleep.
D. The code will not compile unless add codes to catch the
InterruptedException.
E. An exception is thrown at runtime.
100. What is the result?
A. AERZ
B. AR
C. ARZ
D. AZR
E. RAZ
F. Compilation fails.
101. 5. Which code will excute go() in a separate thread? (Choose
all that apply.)
A. new Thread() { public void start() { go(); }}.start();
B. new Thread() { public void run() { go(); }}.run();
C. new Thread() { public void start() { go(); }}.run();
D. new Thread() { public void run() { go(); }}.start();
E. new Thread(new Runnable(){public void run()
{go();}}).start();
F. new Thread(new Runnable(){public void start()
{go();}}).run();
102.
103. 6. Which code fragment will compile ? (Choose all that
apply. )
A. public synchronized Object obj;
B. public synchronized void go() { };
C. public synchronized(this) void go() { };
D. void go() {synchronized() { } };
E. void go() {synchronized(this) { } };
F. void go() {synchronized(Object.class) { } };
G. void go() {synchronized(new Object()) { } };
105. Which statements are true? (Choose all that apply. )
A. It prints "1" and "2".
B. It prints an exception message.
C. It prints "1" and an exception message.
D. It prints "2", "1", and an exception message.
E. It prints "1", an exception message, and "2".
F. It prints "2", an exception message, and "1".
G. Compilation fails.
107. Which changes must be made to adapt this class to be
thread-safe? (Choose al l that apply.)
A. Declare Adder() to be synchronized.
B. Declare getName() to be synchronized.
C. Declare add() to be synchronized.
D. Declare reset() to be synchronized.
E. Declare getSum() to be synchronized.
F. Declare getBase() to be synchronized.