1 y Module 1-JAVA 基础一、选择题: Question 1 Given: 35. String #name = "Jane Doe"; 36. int $age=24; 37. Double _height = ; 38. double ~temp = ; Which two are true? (Choose two.) A. Line 35 will pile. B. Line 36 will pile. C. Line 37 will pile. D. Line 38 will pile. Answer: AD 标识符以字母,下划线,或者$ 开始 Question 2 Given: 11. public class Test { 12. public static void main(String [] args) { 13. int x =5; 14. boolean b1 = true; 15. boolean b2 = false; 16. ((x==4) && !b2) 18. ("l "); 19. ("2 "); 20. if ((b2 = true) && b1) 21. ("3"); 22. } 23. } What is the result? A. 2 B. 3 C. 12 D. 23 E. 123 F. Compilation fails. G. An exceptional is thrown at runtime. Answer: D 注意 20 行, = 为赋值,不要被骗 Question 3 Given: 42. public class ClassA { 43. public int getValue() { 44. int value=0; 45. boolean setting = true; 46. String title="Hello"; 47. if ( value || (setting && title == "Hello")) { return 1; } 48. if (value == 1& ("Hello")) { return 2; } 49. } 50. } And: 70. ClassA a= new ClassA(); 2 71. (); What is the result? A. 1 B. 2 C. Compilation fails. D. The code runs with no output. E. An exception is thrown at runtime. Answer: C 编译不通过, 47 行 value 为 int 类型不是 boolean Question 4 Given: 11. public void testIfA() { 12. if(testIfB("True")) { 13. ("True"); 14. } else { 15. ("Not true"); 16. } 17. } 18. public Boolean testIfB(String str) { 19. return (str) ; 20. } What is the result when method testIfA is invoked? A. True B. Not true C. An exception is thrown at runtime. D. Compilation fails because of an error at line 12. E. Compilation fails because of an error at line 19. Answer: A 19 行,如果 str 为 true 则返回 ture ,否则返回 false Question 5 Given: 11. public static void main(String[] args) { 12. Integer i= new Integer(1) + new Integer(2); 13. switch(i) { 14. case 3: ("three"); break; 15. default: ("other"); break; 16. } 17. } What is the result? A
SUN公司SCJP题库 来自淘豆网www.taodocs.com转载请标明出处.