1.

The static method Thread.currentThread() returns a reference to the currently executing Thread object. What is the result of this code?
 class Test { public static void main(String [] args) { printAll(args); } public static void printAll(String[] lines) { for(int i = 0; i < lines.length; i++) { System.out.println(lines[i]); Thread.currentThread().sleep(1000); } } } 

A. Each String in the array lines will output, with a 1-second pause.
B. Each String in the array lines will output, with no pause in between because this method is not executed in a Thread.
C. Each String in the array lines will output, and there is no guarantee there will be a pause because currentThread() may not retrieve this thread.
D. This code will not compile.
Answer» E.


Discussion

No Comment Found