–2
NaN
Infinity
Compilation fails.
An exception is thrown at runtime.
第1题:
int i = 1,j = 10; do{ if (i>j) { continue; } j--; } while (++i <6); System.out.println(“i = “ +i+” and j = “+j); What is the result?()
第2题:
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?()
第3题:
下面程序段的输出结果是( )。 public class Test{ public static void main(String args[]){ int X,y; x=(int)Math.sqrt(5)/2+(int)Math.random*5/2; y=(int)Math.sqrt(3)/2+(int)Math.random*3/2; if(x>v) System.OUt.println("x>y"); elseif(x= =y) System.out.println("x=Y"); else System.out.println("x<y"): } }
A.x>y
B.x=Y
C.x<y
D.编译错误
第4题:
int i = 0; while (true) { if(i==4) { break; } ++i; } System.out.println(“i=”+i); What is the result?()
第5题:
Given: 11. String test = "This is a test"; 12. String[] tokens = test.split("/s"); 13. System.out.println(tokens.length); What is the result?()
第6题:
class MyThread extends Thread { public void run() { System.out.println(“AAA”); } public void run(Runnable r) { System.out.println(“BBB”); } public static void main(String[] args) { new Thread(new MyThread()).start(); } } What is the result?()
第7题:
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?()
第8题:
A.–2
B.NaN
C.Infinity
D.Compilationfails.
E.Anexceptionisthrownatruntime.
第9题:
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?()
第10题:
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?()