finished
Compilation fails.
An AssertionError is thrown and finished is output.
An AssertionError is thrown with the message “assertion failed”.
An AssertionError is thrown with the message “assertion passed”.
第1题:
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?()
第2题:
public class Test { public static void main(String[] args) { String str = NULL; System.out.println(str); } } What is the result?()
第3题:
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.printIn(j); ] } 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题:
public class Test { public static void main(String[] args) { int x = 0; assert (x > 0) ? “assertion failed” : “assertion passed”; System.out.println(“Finished”); } } 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题:
0
1
2
Compilation fails.
第9题:
passed stuff
stuff passed
passed An AssertionError is thrown with the word “stuff” added to the stack trace.
passed An AssertionError is thrown without the word “stuff” added to the stack trace.
passed An AssertionException is thrown with the word “stuff” added to the stack trace.
passed An AssertionException is thrown without the word “stuff” added to the stack trace.
第10题:
finally
exception finished
finally exception finished
Compilation fails.
第11题:
Compilation fails.
Compilation succeeds with errors.
Compilation succeeds with warnings.
Compilation succeeds without warnings or errors.
第12题:
0
3
Compilation fails.
An exception is thrown at runtime.
第13题:
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?()
第14题:
public class Test { public static void aMethod() throws Exception { try { throw new Exception(); } finally { System.out.println(“finally”); } } public static void main(String args[]) { try { aMethod(); } catch (Exception e) { System.out.println(“exception”); } System.out.println(“finished”); } } What is the result?()
第15题:
public class Test { public static void main(String args[]) { class Foo { public int i = 3; } Object o = (Object)new Foo(); Foo foo = (Foo)o; System.out.println(“i = “ + foo.i); } } What is the result?()
第16题:
public class Foo { public static void main(String[] args) { try { return; } finally { System.out.println( “Finally” ); } } } 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题:
0
1
2
Compilation fails.
第20题:
x = 0
x = 42
Compilation fails because of an error in line 2 of class Test2.
Compilation fails because of an error in line 3 of class Test1.
Compilation fails because of an error in line 4 of class Test2.
第21题:
finished
Compilation fails.
An AssertionError is thrown and finished is output.
An AssertionError is thrown with the message “assertion failed”.
An AssertionError is thrown with the message “assertion passed”.
第22题:
Compilation will fail.
Compilation will succeed and the program will print “0”
Compilation will succeed and the program will print “1”
Compilation will succeed and the program will print “2”
第23题:
NULL
Compilation fails.
The code runs with no output.
An exception is thrown at runtime.
第24题:
finished
Compilation fails.
An AssertionError is thrown.
An AssertionError is thrown and finished is output.