複選題
第6題 Given: 1. public class Breaker{ 2. static String o = ""; 3. public static void main(String[] args){ 4. z: 5. o = o + 2; 6. for(int x=3; x<8; x++){ 7. if(x == 4) break; 8. if(x == 6) break z; 9. o = o + x; 10. } 11. System.out.println(o); 12. } 13. } What is the result?
(A) 23
(B) 234
(C) 235
(D) 2345
(E) 2357 A
(B) 23457 A
(C) Compilation fails.

答案:登入後查看
統計: A(105), B(36), C(135), D(32), E(32) #1157011

詳解 (共 6 筆)

#2370695
(C) Compilation fail...
(共 54 字,隱藏中)
前往觀看
3
0
#3520828
Break遇到不是直接跳離開
請問C的原因是?
1
0
#4178504

這題應該要切兩次來看

static String o = "";

static String c = "";


public static void main(String[] args) {

o = o + 2;

for (int x = 3; x < 8; x++) {

if (x == 4)

break;

o = o + x;

}

c = c + 2;

z: 

for (int x = 3; x < 8; x++) {

if (x == 6)

break z;

c = o + x;

}

System.out.println(o);

System.out.println(c);

}

}

o = 23
c = 235

0
0
#2370984
原本答案為99,修改為A,C
(共 16 字,隱藏中)
前往觀看
0
1
#2370985
原本題目:第6題 Given: 1. p...
(共 715 字,隱藏中)
前往觀看
0
0
#1455357
1. public class Breaker{ 
2. static String o = ""; 
3. public static void main(String[] args){ 
4. z: 
5. o = o + 2; 
6. for(int x=3; x<8; x++){ 
7. if(x == 4) break; 
8. if(x == 6) break z; 
9. o = o + x; 
10. } 
11. System.out.println(o); 
12. } 
13. } 
What is the result? 
(A) 23 
(B) 234 
(C) 235 
(D) 2345 
(E) 2357 A
(B) 23457 A
(C) Compilation fails.

0
0