| 贵州学习网—属于你的学习中心 |
|
1. given: 1. public class test ( 2. public static void main (string args[]) { 3. int i = 0xfffffff1; 4. int j = ~i; 5. 6. } 7. ) what is the decimal value of j at line 5? a. 0 b. 1 c. 14 d. -15 e. an error at line 3 causes compilation to fail. f. an error at line 4 causes compilation to fail. //考点:按位取反的操作符使用 2. given: integer i = new integer (42); long 1 = new long (42); double d = new double (42.0); which two expressions evaluate to true? (choose two) a. (i ==1) b. (i == d) c. (d == 1) d. (i.equals (d)) e. (d.equals (i)) f. (i.equals (42)) //考点:==和equals方法的区别 3. click the exhibit button: 1. public class test ( 2. private static int j = 0; 3. 4. private static boolean methodb(int k) ( 5. j += k; 6. return true; 7. ) 8. 9. public static void methoda(int i) { 10. boolean b: 11. b = i < 10 | methodb (4); 12. b = i < 10 || methodb (8); 13. ) 14. 15. public static void main (string args[] } ( 16. methoda (0); 17. system.out.printin(j); 18. ) 19. ) what is the result? a. the program prints “0” b. the program prints “4” c. the program prints “8” d. the program prints “12” e. the code does not complete //考点:或运算和短逻辑或运算 4. given: 1.public class test ( 2. public static void main (string args[]) ( 3. system.out.printin (6 ^ 3); 4. ) 5.) what is the output? ans: //考点:异或的符号实际使用 5. given: 1. public class foo { 2. public static void main (string [] args) { 3. stringbuffer a = new stringbuffer (“a”); 4. stringbuffer b = new stringbuffer (“b”); 5. operate (a,b); 6. system.out.printin{a + “,” +b}; 7. ) 8. static void operate (stringbuffer x, stringbuffer y) { 9. x.append {y}; 10. y = x; 11. ) 12. } what is the result? a. the code compiles and prints “a,b”. b. the code compiles and prints “a,a”. c. the code compiles and prints “b,b”. d. the code compiles and prints “ab,b”. e. the code compiles and prints “ab,ab”. f. the code does not compile BECause “+” cannot be overloaded for stringbuffer. //考点:stringbuffer类的使用方法 6. click the exhibit button: 1. public class test ( 2. public static void stringreplace (string text) ( 3. text = text.replace (‘j’ , ‘i’); 4. ) 5. 6. public static void bufferreplace (stringbuffer text) ( 7. text = text.append (“c”) 8. ) 9. 10. public static void main (string args[]} ( 11. string textstring = new string (“Java”); 12. stringbuffer text bufferstring = new stringbuffer (“java”); 13. 14. stringreplace (textstring); 15. bufferreplace (textbuffer); 16. 17. system.out.printin (textstring + textbuffer); 18. } 19. ) what is the output? ans: //考点:string 和stringbuffer类的方法和使用
7. click the exhibit button: 1. public class test { 2. public static void add3 (integer i) } 3. int val = i.intvalue ( ); 4. val += 3; 5. i = new integer (val); 6. } 7. 8. public static void main (string args [ ] ) { 9. integer i = new integer (0); 10. add3 (i); 11. system.out.printin (i.intvalue ( ) ); 12. } 13. ) |
责任编辑:gzu521