单项选择题
public class Threads3 implements Runnable {
public void run() {
System.out.print(”running”);
}
public static void main(String[] args) {
Thread t = new Thread(new Threads3());
t.run();
t.run();
t.start();
}
}
What is the result?()
A. Compilation fails.
B. An exception is thrown at runtime.
C. The code executes and prints “running”.
D. The code executes and prints “runningrunning”.
E. The code executes and prints “runningrunningrunning”.
相关考题
-
多项选择题
WhichtwocodefragmentswillexecutethemethoddoStuff()inaseparatethread?()
A. new Thread() { public void run() { doStuff(); } }
B. new Thread() { public void start() { doStuff(); } }
C. new Thread() { public void start() { doStuff(); } } .run();
D. new Thread() { public void run() { doStuff(); } } .start();
E. new Thread(new Runnable() { public void run() { doStuff(); } } ).run();
F. new Thread(new Runnable() { public void run() { doStuff(); } }).start(); -
单项选择题
12. String csv = “Sue,5,true,3”; 13. Scanner scanner = new Scanner( csv); 14. scanner.useDelimiter(”,”); 15. int age = scanner.nextInt(); What is the result?()
A. Compilation fails.
B. After line 15, the value of age is 5.
C. After line 15, the value of age is 3.
D. An exception is thrown at runtime. -
单项选择题
System.out.format(”Pi is approximately %d.”, Math.PI); What is the result?()
A. Compilation fails.
B. Pi is approximately 3.
C. Pi is approximately 3.141593.
D. An exception is thrown at runtime.
