複選題
第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
統計: A(105), B(36), C(135), D(32), E(32) #1157011
詳解 (共 6 筆)
#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
#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