1. 

Which statement is true?

A. A static method cannot be synchronized.
B. If a class has synchronized code, multiple threads can still access the nonsynchronized code.
C. Variables can be protected from concurrent access problems by marking them with the synchronized keyword.
D. When a thread sleeps, it releases its locks.

2. 

Which two can be used to create a new Thread?

  1. Extend java.lang.Thread and override the run() method.
  2. Extend java.lang.Runnable and override the start() method.
  3. Implement java.lang.Thread and implement the run() method.
  4. Implement java.lang.Runnable and implement the run() method.
  5. Implement java.lang.Thread and implement the start() method.

A. 1 and 2
B. 2 and 3
C. 1 and 4
D. 3 and 4

3. 

The following block of code creates a Thread using a Runnable target:

Runnable target = new MyRunnable();
Thread myThread = new Thread(target);
Which of the following classes can be used to create the target, so that the preceding code compiles correctly?

A. public class MyRunnable extends Runnable{public void run(){}}
B. public class MyRunnable extends Object{public void run(){}}
C. public class MyRunnable implements Runnable{public void run(){}}
D. public class MyRunnable implements Runnable{void run(){}}

4. 

Which two statements are true?

  1. Deadlock will not occur if wait()/notify() is used
  2. A thread will resume execution as soon as its sleep duration expires.
  3. Synchronization can prevent two objects from being accessed by the same thread.
  4. The wait() method is overloaded to accept a duration.
  5. The notify() method is overloaded to accept a duration.
  6. Both wait() and notify() must be called from a synchronized context.

A. 1 and 2
B. 3 and 5
C. 4 and 6
D. 1 and 3

5. 

Which statement is true?

A. The notifyAll() method must be called from a synchronized context.
B. To call wait(), an object must own the lock on the thread.
C. The notify() method is defined in class java.lang.Thread.
D. The notify() method causes a thread to immediately release its locks.