–2
NaN
Infinity
Compilation fails.
An exception is thrown at runtime.
第1题:
int i = 0, j = 5; tp; for (;;) { i++; for(;;) { if (i> --j) { break tp; break tp; } } System.out.println(“i=” +i “,j =”+j); } What is the result?()
第2题:
Given: 11. String test = "This is a test"; 12. String[] tokens = test.split("/s"); 13. System.out.println(tokens.length); What is the result?()
第3题:
int i = 0; while (true) { if(i==4) { break; } ++i; } System.out.println(“i=”+i); What is the result?()
第4题:
try { if ((new Object))(.equals((new Object()))) { System.out.println(“equal”); }else{ System.out.println(“not equal”); } }catch (Exception e) { System.out.println(“exception”); } What is the result? ()
第5题:
System.out.println(Math.sqrt(-4D)); What is the result?()
第6题:
finally
exception finished
finally exception finished
Compilation fails.
第7题:
a
b
c
d
Compilation fails.
第8题:
0 2 4
0 2 4 5
0 1 2 3 4
Compilation fails.
An exception is thrown at runtime.
第9题:
test
Exception
Compilation fails.
NullPointerException
第10题:
finished
Exception
Compilation fails.
Arithmetic Exception
第11题:
equal
not equal
exception
Compilation fails.
第12题:
An exception is thrown at runtime.
1
4
Compilation fails.
0
第13题:
public static void main(String[] args) { String str = “null‟; if (str == null) { System.out.println(”null”); } else (str.length() == 0) { System.out.println(”zero”); } else { System.out.println(”some”); } } What is the result?()
第14题:
boolean bool = true; if(bool = false) { System.out.println(“a”); } else if (bool) { System.out.println(“c”); } else if (!bool) { System.out.println(“c”); } else { System.out.println(“d”); } What is the result?()
第15题:
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?()
第16题:
public void testIfA(){ if(testIfB("True")){ System.out.println("True"); }else{ System.out.println("Nottrue"); } } public Boolean testIfB(Stringstr){ return Boolean.valueOf(str); } What is the result when method testIfA is invoked?()
第17题:
String a = null; a.concat(“abc”); a.concat(“def”); System.out.println(a); What is the result?()
第18题:
i = 0
i = 3
i = 4
i = 5
Compilation fails.
第19题:
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
第20题:
True
Nottrue
Anexceptionisthrownatruntime.
Compilationfailsbecauseofanerroratline12.
Compilationfailsbecauseofanerroratline19.
第21题:
null
zero
some
Compilation fails.
An exception is thrown at runtime.
第22题:
–2
NaN
Infinity
Compilation fails.
An exception is thrown at runtime.
第23题:
null
zero
some
Compilationfails.
Anexceptionisthrownatruntime.
第24题:
0
2
4
6
9
13