f[0] = 0
f[0] = 0.0
Compilation fails.
An exception is thrown at runtime.
第1题:
public class ArrayTest { public static void main(String[] args) { float fl[], f2[]; fl = new float[10]; f2 = f1; System.out.println(“f2[0]= “ + f2[0]); } } What is the result?()
第2题:
public class Alpha{ public static void main( string[] args ){ if ( args.length == 2 ) { if ( args.[0].equalsIgnoreCase(“-b”) ) System.out.println( new Boolean( args[1] )); } } } And the code is invoked by using the command: java Alpha –b TRUE What is the result?()
第3题:
public class Test { private static float[] f = new float[2]; public static void main(String args[]) { System.out.println(“f[0] = “ + f[0]); } } What is the result?()
第4题:
public class Test { public int aMethod() { static int i = 0; i++; return i; } public static void main (String args[]) { Test test = new Test(); test.aMethod(); int j = test.aMethod(); System.out.println(j); } } What is the result?()
第5题:
1. public class ArrayTest { 2. public static void main (String[]args) { 3. float f1[], f2[]; 4. f1 = new float [10]; 5. f2 = f1; 6. System.out.printIn (“f2[0]=” + f2[0]); 7. } 8. } What is the result?()
第6题:
public class Test { public static void main(String[] args) { int x = 0; assert (x > 0): “assertion failed”; System.out.println(“finished”); } } What is the result?()
第7题:
0
null
Compilation fails.
A NullPointerException is thrown at runtime.
An ArrayIndexOutOfBoundsException is thrown at runtime.
第8题:
It prints f2[0] = 0.0.
It prints f2[0] = NaN.
An error at line 5 causes compile to fail.
An error at line 6 causes compile to fail.
An error at line 6 causes an expectation at runtime.
第9题:
0
1
2
Compilation fails.
第10题:
6
7
10
11
Compilation fails.
An exception is thrown at runtime.
第11题:
0.0
Compilation fails.
A ParseException is thrown by the parse method at runtime.
A NumberFormatException is thrown by the parse method at runtime.
第12题:
It prints f2[0] = 0.0
It prints f2[0] = NaN
An error at line 5 causes compile to fail.
An error at line 6 causes compile to fail.
An error at line 6 causes an exception at runtime.
第13题:
public static void parse(String str) { try { float f= Float.parseFloat(str); } catch (NumberFormatException nfe) { f= 0; } finally { System.out.println(f); } } public static void main(String[] args) { parse(”invalid”); } What is the result?()
第14题:
class Super { public int i = 0; public Super(String text) { i = 1; } } public class Sub extends Super { public Sub(String text) { i = 2; } public static void main(String args[]) { Sub sub = new Sub(“Hello”); System.out.println(sub.i); } } What is the result?()
第15题:
class TestA { public void start() { System.out.println(”TestA”); } } public class TestB extends TestA { public void start() { System.out.println(”TestB”); } public static void main(String[] args) { ((TestA)new TestB()).start(); } } What is the result?()
第16题:
public static void main(String[] args) { try { args=null; args[0] = “test”; System.out.println(args[0]); } catch (Exception ex) { System.out.println(”Exception”); } catch (NullPointerException npe) { System.out.println(”NullPointerException”); } } What is the result?()
第17题:
public class Test { private static int[] x; public static void main(String[] args) { System.out.println(x[0]); } } What is the result?()
第18题:
f[0] = 0
f[0] = 0.0
Compilation fails.
An exception is thrown at runtime.
第19题:
test
Exception
Compilation fails.
NullPointerException
第20题:
It prints f2[0] = 0.0
It prints f2[0] = NaN
An error at line 5 causes compile to fail.
An error at line 6 causes compile to fail.
An error at line 6 causes an exception at runtime.
第21题:
end
Compilation fails.
exception end
exception test end
A Throwable is thrown by main.
An Exception is thrown by main.
第22题:
true
null
false
Compilation fails.
The code runs with no output.
An exception is thrown at runtime.
第23题:
0
3
Compilation fails.
An exception is thrown at runtime.
第24题:
finished
Compilation fails.
An AssertionError is thrown.
An AssertionError is thrown and finished is output.