|
选择题 1: In the following code, which is the earliest statement, where the object originally held in e, may be garbage collected: 1.public class Test { 2. public static void main (String args []) { 3. Employee e = new Employee("Bob", 48); 4. e.calculatePay(); 5. System.out.println(e.printDetails()); 6. e = null; 7. e = new Employee("Denise", 36); 8. e.calculatePay(); 9. System.out.println(e.printDetails()); 10. } 11.} Only One: In the following code, which is the earliest statement, where the object originally held in e, may be garbage collected: 1.public class Test { 2. public static void main (String args []) { 3. Employee e = new Employee("Bob", 48); 4. e.calculatePay(); 5. System.out.println(e.printDetails()); 6. e = null; 7. e = new Employee("Denise", 36); 8. e.calculatePay(); 9. System.out.println(e.printDetails()); 10. } 11.} Only One: A.Line 10 B.Line 11 C.Line 7 D.Line 8 2:Exhibit : 1. public class test ( 2. private static int j = 0; 3. 4. private static boolean methodB(int k) ( 5. j += k; 6. return true; 6. ) 7. 8. public static void methodA(int i) { 9. boolean b: 10. b = i < 10 | methodB (4); 11. b = i < 10 || methodB (8); 12. ) 13. 14. public static void main (String args[] } ( 15. methodA (0); 16. system.out.printIn(j); 17. ) 18. ) What is the result? A.The program prints “0” B.The program prints “4” C.The program prints “8” D.The program prints “12” 3:What is written to the standard output given the following statement:System.out.println(4|7); Select the right answer: A.4 B.5 C.6 D.7 4: Select valid identifier of Java: Select valid identifier of Java: A.%passwd B.3d_game C.$charge D.this 5:设有变量说明语句int a=1,b=0; 则执行以下程序段的输出结果为( )。 switch (a) { case 1: switch (b) { case 0:printf("**0**");break; case 1:printf("**1**");break; } case 2:printf("**2**");break; } printf(" "); A.**0** B.**0****2** C.**0****1****2** D.有语法错误 6:In the following pieces of code, which one will compile without any error? A.StringBuffer sb1 = "abcd"; B.Boolean b = new Boolean("abcd"); C.C: byte b = 255; D.float fl = 1.2; 7: What is the result when you compile and run the following code? public class ThrowsDemo { static void throwMethod() { System.out.println("Inside throwMethod."); throw new IllegalAccessException("demo"); } public static void main(String args[]) { try { throwMethod(); } catch (IllegalAccessException e) { System.out.println("Caught " + e); } } } Choices: What is the result when you compile and run the following code? public class ThrowsDemo { static void throwMethod() { System.out.println("Inside throwMethod."); throw new IllegalAccessException("demo"); } public static void main(String args[]) { try { throwMethod(); } catch (IllegalAccessException e) { System.out.println("Caught " + e); } } } Choices: A.Compilation error B.Runtime error C.Compile successfully, nothing is printed. D.Inside throwMethod. followed by caught:java.lang.IllegalAccessExcption: demo (责任编辑:职场达人) |


