"SCJP 1.6版考題 163" 修訂間的差異

出自 陳富國維基館
前往: 導覽搜尋
(新頁面: Given: 1. public class TestString3{ 2. public static void main(String[] args){ 3. //insert code here 5. System.out.println(s); 6. } 7. } Which two code fragments,...)
 
(無差異)

於 2013年3月30日 (六) 02:29 的最新修訂

Given:
1. public class TestString3{
2.   public static void main(String[] args){
3.     //insert code here
5.     System.out.println(s);
6.   }
7. }

Which two code fragments, inserted independently at line 3, generate the output 4247? (choose two.)
 A. String s = "123456789";
      s = (s - "123").replace(1, 3, "24") - "89";
 B. StringBuffer s = new StringBuffer("123456789");
      s.delete(0, 3).replace(1, 3, "24").delete(4, 6);
 C. StringBuffer s = new StringBuffer("123456789");
      s.substring(3, 6).delete(1, 3).insert(1, "24");
 D. StringBuilder s = new StringBuilder("123456789");
      s.substring(3, 6).delete(1, 2).insert(1, "24");
 E. StringBuilder s = new StringBuilder("123456789");
      s.delete(0, 3).delete(1, 3).delete(2, 5).insert(1, "24");

解答


Ans: B E

解說: 第3行分別地插入那二個敘述可以輸出4247?