单选题 System.out.println(Math.sqrt(-4D)); What is the result?()
–2
NaN
Infinity
Compilation fails.
An exception is thrown at runtime.
单选题 public class Test { public static void main (String args) { string foo = “blue”; string bar = foo; foo = “green”; System.out.printIn(bar); } } What is the result?()
An exception is thrown.
The code will not compile.
The program prints “null”
The program prints “blue”
The program prints “green”
单选题 Given two files, GrizzlyBear.java and Salmon.java: If both classes are in the correct directories for their packages, and the Mammal class correctly defines the findSalmon() method, which change allows this code to compile?()
add import animals. mammals.*; at line 2 in Salmon.java
add import animals.fish.*; at line 2 in GrizzlyBearjava
add import animals.fish.Salmon.*; at line 2 in GrizzlyBear.java
add import animals. mammals.GrizzlyBear*; at line 2 in Salmon.java
单选题 int x = 1, y =6; while (y--) { x++; } System.out.println(“x =” + x + “y =” +y); What is the result?()
x = 6 y = 0
x = 7 y = 0
x = 6 y = -1
x = 7 y = -1
Compilation fails.
单选题 What is the result?()
Compilation fails.
After line 15, the value of age is 5.
After line 15, the value of age is 3.
An exception is thrown at runtime.
单选题 Given: 310-025 Leading the way in IT testing and certification tools, www.testking.com - 48 - public class foo { static String s; public static void main (Stringargs) { system.out.printIn (“s=” + s); } } What is the result?()
The code compiles and “s=” is printed.
The code compiles and “s=null” is printed.
The code does not compile because string s is not initialized.
The code does not compile because string s cannot be referenced.
The code compiles, but a NullPointerException is thrown when toString is called.
单选题 public class SwitchTest { public static void main(String[] args) { System.out.println(“value = “ + switchIt(4)); } public static int switchIt(int x) { int j = 1; switch (x) { case 1: j++; case 2: j++; case 3: j++; case 4: j++; case 5: j++; default: j++; } return j + x; } } What is the result?()
value = 3
value = 4
value = 5
value = 6
value = 7
value = 8
单选题 public class X { public object m () { object o = new float (3.14F); object oa = new object [1]; oa[0]= o; o = null; oa[0] = null; return o; } } When is the float object created in line 3, eligible for garbage collection?()
Just after line 5.
Just after line 6.
Just after line 7.
Just after line 8(that is, as the method returns).
单选题 public class Test { public static void leftshift(int i, int j) { i<<=j; } public static void main(String args) { int i = 4, j = 2; leftshift(i, j); System.out.printIn(i); } } What is the result? ()
2
4
8
16
The code will not compile.
单选题 int i= 1, j= 10 ; do ( if (i++> --j) continue; ) while (i<5); After execution, what are the values for I and j? ()
i = 6 and j= 5
i = 5 and j= 5
i = 6 and j= 4
i = 5 and j= 6
i = 6 and j= 6