public class X implements Runnable ( private int x; private int y; public static void main(String [] args) ( X that = new X(); (new Thread(that)) . start( ); (new Thread(that)) . start( ); ) public synchronized void run( ) ( for (;;) ( x++; y++; System.out.printIn(“x = “ + x + “, y = “ + y); ) ) ) What is the result?()
A、 An error at line 11 causes compilation to fail.
B、 Errors at lines 7 and 8 cause compilation to fail.
C、 The program prints pairs of values for x and y that might not always be the same on the same line (for example, “x=2, y=1”)
D、 The program prints pairs of values for x and y that are always the same on the same line (for example, “x=1, y=1”. In addition, each value appears twice (for example, “x=1, y=1” followed by “x=1, y=1”)
E、 The program prints pairs of values for x and y that are always the same on the same line (for example, “x=1, y=1”. In addition, each value appears twice (for example, “x=1, y=1” followed by “x=2s, y=2”)
相关问题推荐
-
public class Pass { public static void main(String [1 args) { int x 5; Pass p = new Pass(); p.doStuff(x); System.out.print(” main x = “+ x); } void doStuff(int x) { System.out.print(” doStuff x = “+ x++); } } What is the result?()
A、 Compilation fails.
B、 An exception is thrown at runtime.
C、 doStuffx = 6 main x = 6
D、 doStuffx = 5 main x = 5
E、 doStuffx = 5 main x = 6
F、 doStuffx = 6 main x = 5
-
35. String #name = “Jane Doe”; 36. int$age=24; 37. Double_height = 123.5; 38. double~temp = 37.5; Which two are true?()
ALine 35 will not compile.
BLine 36 will not compile.
CLine 37 will not compile.
DLine 38 will not compile.
-
public class ForBar { public static void main(String args) { int i = 0, j = 5; tp: for (;;) { i ++; for(;;) if(i > --j) break tp; } system.out.printIn(“i = ” + i + “, j = “+ j); } } What is the result? ()
A、 The program runs and prints “i=1, j=0”
B、 The program runs and prints “i=1, j=4”
C、 The program runs and prints “i=3, j=4”
D、 The program runs and prints “i=3, j=0”
E、 An error at line 4 causes compilation to fail.
F、 An error at line 7 causes compilation to fail.
-
public void test(int x) { int odd = x%2; if (odd) { System.out.println(“odd); } else { System.out.println(“even”); } } Which statement is true?()
A、Compilation fails.
B、 “odd” will always be output.
C、 “even” will always be output.
D、 “odd” will be output for odd values of x, and “even” for even values.
E、 “even” will be output for add values of x, and “odd” for even values.
-
What is the result?()
A、 end
B、 Compilation fails.
C、 exception end
D、 exception test end
E、 A Throwable is thrown by main.
F、 An Exception is thrown by main.