4:
1.10 What is the result of compiling and executing the following code?
public class ThreadTest extends Thread {
public void run() {
System.out.println("In run");
yield(); System.out.println("Leaving run");
}
public static void main(String args []) {
(new ThreadTest()).start();
}
}
A. The code fails to compile in the main() method.
B. The code fails to compile in the run() method.
C. Only the text "In run" will be displayed.
D. The text "In run" followed by "Leaving run" will be displayed.
E. The code compiles correctly, but nothing is displayed.
Answer: D
5:
1.12 Which of the following will definitely stop a thread from executing?A. wait()B. notify()C. yield()D. suspend()E. sleep()Answer: ACDE
6:
1.12 Which of the following will definitely stop a thread from executing?
A. wait()
B. notify()
C. yield()
D. suspend()
E. sleep()
Answer: ACDE
編輯推薦:
(責任編輯:xy)