The program runs and prints nothing.
The program runs and prints “Equal”.
An error at line 5 cause compilation to fail.
The program runs but aborts with an exception.
第1题:
public class foo { public static void main (string[]args) try {return;} finally {system.out.printIn(“Finally”);} } What is the result?()
第2题:
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? ()
第3题:
public class X { public static void main (String[]args) { string s = new string (“Hello”); modify(s); System.out.printIn(s); } public static void modify (String s) { s += “world!”; } } What is the result?()
第4题:
public class test { public static void add3 (Integer i){ int val = i.intValue ( ); val += 3; i = new Integer (val); } public static void main (String args [ ] ) { Integer i = new Integer (0); add3 (i); system.out.printIn (i.intValue ( ) ); } } What is the result?()
第5题:
The program runs and prints “0”
The program runs and prints “1”
The program runs but aborts with an exception.
An error “possible undefined variable” at line 4 causes compilation to fail.
An error “possible undefined variable” at line 9 causes compilation to fail.
第6题:
The program runs and prints nothing.
The program runs and prints “Equal”
An error at line 5 causes compilation to fail.
The program runs but aborts with an exception.
第7题:
The program runs and prints “Hello”
An error causes compilation to fail.
The program runs and prints “Hello world!”
The program runs but aborts with an exception.
第8题:
The program runs and prints “Hello”
An error causes compilation to fail.
The program runs and prints “Hello world!”
The program runs but aborts with an exception.
第9题:
The program runs and prints nothing.
The program runs and prints “Finally”
The code compiles, but an exception is thrown at runtime.
The code will not compile because the catch block is missing.
第10题:
An exception is thrown.
The code will not compile.
The program prints “null”
The program prints “blue”
The program prints “green”
第11题:
The program prints “0”.
The program prints “4”.
The program prints “8”.
The program prints “12”.
The code does not compile.
第12题:
The program runs and prints “0”
The program runs and prints “1”
The program runs but aborts with an exception.
An error “possible undefined variable” at line 4 causes compilation to fail.
An error “possible undefined variable” at line 9 causes compilation to fail.
第13题:
public class X { public static void main (Stringargs) { int a = new int [1] modify(a); System.out.printIn(a[0]); } public static void modify (int a) { a[0] ++; } } What is the result?()
第14题:
public class X { public static void main (Stringargs) { String s1 = new String (“true”); Boolean b1 = new Boolean (true); if (s2.equals(b1)) { System.out.printIn(“Equal”); } } } What is the result? ()
第15题:
public class Test { public static void replaceJ(string text) { text.replace (‘j’, ‘l’); } public static void main(String args[]) { string text = new String (“java”) replaceJ(text); system.out.printIn(text); } } What is the result?()
第16题:
Given 1. public class Foo { 2. public static void main (String [] args) } 3. try { return;} 4. finally { Syste.out.printIn (“Finally”);} 5. } 6. } What is the result( )?
第17题:
The program runs and prints “i=1, j=0”
The program runs and prints “i=1, j=4”
The program runs and prints “i=3, j=4”
The program runs and prints “i=3, j=0”
An error at line 4 causes compilation to fail.
An error at line 7 causes compilation to fail.
第18题:
The program runs and prints nothing.
The program runs and prints “Equal”
An error at line 5 causes compilation to fail.
The program runs but aborts with an exception.
第19题:
The program runs and prints “i=1, j=0”
The program runs and prints “i=1, j=4”
The program runs and prints “i=3, j=4”
The program runs and prints “i=3, j=0”
An error at line 4 causes compilation to fail.
An error at line 7 causes compilation to fail.
第20题:
The program runs and prints nothing.
The program runs and prints “Equal”.
An error at line 5 cause compilation to fail.
The program runs but aborts with an exception.
第21题:
Compilation will fail.
The program prints “0”.
The program prints “3”.
Compilation will succeed but an exception will be thrown at line 3.
第22题:
The program runs and prints nothing.
The program runs and prints “Finally”.
The code comiles. But an exception is thrown at runtime.
The code will not compile because the catch block is missing.
第23题:
The program runs and prints “ I = 1 , j = 0”
The program runs and prints “ I = 1 , j = 4”
The program runs and prints “ I = 3 , j = 4”
The program runs and prints “ I = 3 , j = 0”
An error at line 4 cause compilation to fail.
An error at line 7 cause compilation to fail.
第24题:
The program prints “lava”
The program prints “java”
An error at line 7 causes compilation to fail.
Compilation succeeds but the program throws an exception.