当前位置: 技术问答>java相关
这道题我不明白,能讲讲吗?
来源: 互联网 发布时间:2017-04-02
本文导语: 答案是A、D 1. public class SwitchTest { 2. public static void main (String []args) { 3. System.out.PrintIn(“value =” +switchIt(4)); 4. } 5. public static int switchIt(int x) { 6. int j = 1; 7. switch (x) { 8. case 1: j++; 9. case 2:...
答案是A、D
1. public class SwitchTest {
2. public static void main (String []args) {
3. System.out.PrintIn(“value =” +switchIt(4));
4. }
5. public static int switchIt(int x) {
6. int j = 1;
7. switch (x) {
8. case 1: j++;
9. case 2: j++;
10. case 3: j++;
11. case 4: j++;
12. case 5: j++;
13. default:j++;
14. }
15. return j + x;
16. }
17. }
What is the output from line 3?
A. Value = 3
B. Value = 4
C. Value = 5
D. Value = 6
E. Value = 7
F. Value = 8
1. public class SwitchTest {
2. public static void main (String []args) {
3. System.out.PrintIn(“value =” +switchIt(4));
4. }
5. public static int switchIt(int x) {
6. int j = 1;
7. switch (x) {
8. case 1: j++;
9. case 2: j++;
10. case 3: j++;
11. case 4: j++;
12. case 5: j++;
13. default:j++;
14. }
15. return j + x;
16. }
17. }
What is the output from line 3?
A. Value = 3
B. Value = 4
C. Value = 5
D. Value = 6
E. Value = 7
F. Value = 8
|
F
答案也有错的时候,建议,不要太在意答案而,而把精力放在对知识的理解上!
答案也有错的时候,建议,不要太在意答案而,而把精力放在对知识的理解上!