Monday, September 12, 2011

Quiz of the day | OCPJP (7)

Given:

public class TimeExcelindo extends Thread {
public static void main(String[] args) {
Thread t = new Thread(new TimeExcelindo());
Thread t2 = new Thread(new TimeExcelindo());
t.start();
t2.start();
}
public static void run() {
for(int i = 0; i < 2; i++)
System.out.print(Thread.currentThread().getName() + " ");
}
}

Which are true? (Choose all that apply.)

A. Compilation fails.
B. No output is produced.
C. The output could be Thread-1 Thread-3 Thread-1 Thread-2
D. The output could be Thread-1 Thread-3 Thread-1 Thread-3
E. The output could be Thread-1 Thread-1 Thread-2 Thread-2
F. The output could be Thread-1 Thread-3 Thread-3 Thread-1
G. The output could be Thread-1 Thread-3 Thread-1 Thread-1


DOWNLOAD the answer

0 comments: