1、选择题1:1.What will be the result of executing the following code? 2. 3.public static void main(String args[]) 4.{ 5. char digit = 'a'; 6. for (int i = 0; i < 10; i++) 7. { 8. switch (digit) 9. { 10. case 'x' : 11. { 12. int j = 0; 13. Sy
4、thod.C.Thecodewillnotcompilebecausethevariablejcannotbedeclaredtwicewithintheswitchstatement.D.Noneofthese.2:1.Give the code fragment: 2.if(x>4){ 1.System.out.println(“Test 1”);} 2.else if (x>9){ 3.System.out.println(“Test 2”);} 4.else { 5.System.out.println(“Test 3”);} 6.Which rang
5、e of value x would produce of output “Test 2”? Givethecodefragment:if(x>4){System.out.println(“Test1”);}elseif(x>9){System.out.println(“Test2”);}else{System.out.println(“Test3”);}Whichrangeofvaluexwouldproduceofoutput“Test2”?A.x<4B.x>4C.x>9D.None3:关于垃圾收集的哪些叙述是对的。A.程序开发者必须自己创建一个线程进行内存释放的工
6、作。B.垃圾收集将检查并释放不再使用的内存。C.垃圾收集允许程序开发者明确指定并立即释放该内存。D.垃圾收集能够在期望的时间释放被java对象使用的内存。4:1.Give the following method: 2. public void method( ){ 3. String a,b; 4. a=new String(“hello world”); 5. b=new String(“game over”); 6. System.out.println(a+b+”ok”); 7. a=null; 8. a=b; 9. System.out.print
7、ln(a); 10. } 11.In the absence of compiler optimization, which is the earliest point the object a refered is definitely elibile to be garbage collection. Givethefollowingmethod:publicvoidmethod(){Stringa,b;a=newString(“helloworld”);b=newString(“gameover”);