Java Reference
In-Depth Information
Review Questions
1. Given the following DoSomething class definition:
1. public class DoSomething implements Runnable {
2. public void run() {
3. System.out.println(“Do something”);
4. }
5. }
what is output of the following statements?
10. DoSomething r = new DoSomething();
11. Thread t = new Thread(r);
12. System.out.println(t.getState());
A. Do something
B. The output is indeterminate.
C. NEW
D. RUNNABLE
E. TERMINATED
2. Given the following DoSomething class definition:
1. public class DoSomething implements Runnable {
2. public void run() {
3. System.out.print(“Do something”);
4. }
5. }
what is output of the following program?
1. public class Main {
2. public static void main(String [] args)
3. throws InterruptedException {
4. DoSomething r = new DoSomething();
5. Thread t = new Thread(r);
6. t.start();
7. t.join();
8. System.out.print(“ else “);
9. }
10. }
A. Do something else
B. else Do something
Search WWH ::




Custom Search