还在考1.2的同志请看
文章作者 100test 发表时间 2007:03:14 17:05:02
来源 100Test.Com百考试题网
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. )