Value = 3
Value = 4
Value = 5
Value = 6
Value = 7
Value = 8
第1题:
以下代码的输出结果是什么? class Foo{ public static void main(String args[]){ int x=4,j=0; switch(x){ case 1:j++; case 2:j++; case 3:j++; case 4:j++; case 5:j++; break; default:j++; } System.out.println(j); } }()
A.1
B.2
C.3
D.编译错误
第2题:
1.publicclassSwitchTest{2.publicstaticvoidmain(String[]args){3.System.out.PrintIn(value=”+switchIt(4));4.}5.publicstaticintswitchIt(intx){6.intj=1;7.switch(x){8.case1:j++;9.case2:j++;10.case3:j++;11.case4:j++;12.case5:j++;13.default:j++;14.}15.returnj+x;16.}17.}Whatistheoutputfromline3?()
A.Value=3
B.Value=4
C.Value=5
D.Value=6
E.Value=7
F.Value=8
第3题:
publicclassSwitchTest{publicstaticvoidmain(Stringargs){System.out.PrintIn(value=”+switchIt(4));}publicstaticintswitchIt(intx){intj=1;switch(x){case1:j++;case2:j++;case3:j++;case4:j++;case5:j++;default:j++;}returnj+x;}}Whatistheoutputfromline3?()
A.Value=3
B.Value=4
C.Value=5
D.Value=6
E.Value=7
F.Value=8
第4题:
下面程序段的输出结果是( )。 public class Test t public static void main(String[] args) { int x=0; for (int i=1;i<=4;i++) { x=4; for(int j=1;j<=3; j++) { x=3; for(int k=1; k<=2; k++) x=x+6; } } System. out. println (x); } }
A.36
B.48
C.144
D.15
第5题:
下面程序段的输出结果是( )。 public class Test { public static void main (String[] args) { int j=2,i=5; while (j<i--) j++; System.out.println(j);} }
A.2
B.3
C.4
D.5
第6题:
下列程序的输出的结果是______。 public class exl6 { public static void main(String[] args) { int j=10; for(int i=0;i<3;i++) { j-=i+1; switch (j){ case 3: break; case 5: break; case 8: break; default: j=0;break; } } System,out.println(j); } }
A.5
B.3
C.8
D.0
第7题:
下列程序执行之后,将输出 public class exl9 { public static void main(string[] args) { int x=3; int y=7; switch(y/x){ case 1: y*=2; break; case 2: y*=3; break; case 3: y*=4; break; default: y=0; } System.out.print(y); } }
A.28
B.21
C.14
D.0
第8题:
下列程序输出结果为( )。public class test { public static void main(String args[]) { int a=0; outer: for(int i=0;i<2;i++) { for(int j=0;j<2;j++) { if(j>i) { continue outer; } a++; } } System.out.println(a); }}
A.0
B.2
C.3
D.4
第9题:
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?()
第10题:
public class Test { public static void main(String Args[]) { int i =1, j = 0; switch(i) { case 2: j +=6; case 4: j +=1; default: j +=2; case 0: j +=4; } System.out.println(“j =” +j); } } What is the result? ()
第11题:
0
2
4
6
9
13
第12题:
value = 3
value = 4
value = 5
value = 6
value = 7
value = 8
第13题:
以下程序的输出结果是( )。 #include<iostream.h> void main() { int a(5),b(6),i(0),j(0); switch(a) { case 5:switch(b) { case 5:i++;break; case 6:j++;break; default:i++;j++; } case 6:i++; j++; break; default:i++;j++; } cout<<i<<","<<j<<endl; }
A.1,2
B.1,3
C.2,2
D.2,3
第14题:
publicclassSwitchTest{publicstaticvoidmain(String[]args){System.out.println(value=+switchIt(4));}publicstaticintswitchIt(intx){intj=1;switch(x){case1:j++;case2:j++;case3:j++;case4:j++;case5:j++;default:j++;}returnj+x;}}Whatistheresult?()
A.value=3
B.value=4
C.value=5
D.value=6
E.value=7
F.value=8
第15题:
给出下面代码片段: public class Test{ public static void main (String args[ ]){ int m; switch(m) { case 0:System.out.println("case 0"); case 1:System.out.println("case 1"):break; case 2: default:System.out.println("default"); } } } 下列m的( )值将引起"default"的输出。
A.1
B.2
C.4
D.0
第16题:
给出下列代码段: public class ex38 { public static void main (String args [ ] ) { int m; switch(m) { case 0: System.out.println ( "case 0" ); case 1:System.out.println("case 1");break; case 2: default: System.out.print in ("default") } } 下列m的______值将引起"default"的输出。
A.0
B.1
C.2
D.以上答案都不正确
第17题:
执行如下程序: public class Test { public static void main (String args[]) { int x=1,a=0,b=0; switch (x) { case 0: b++; case 1: a++; case 2: a++;b++; } System.out.println("a=" +a ",b=" +b); } } 该程序的输出结果是( )。
A.a=2,b=1
B.a=1,b=1
C.a=1,b=0
D.a=2,b=2
第18题:
下列语句序列执行后,j的值是______。 public class ex2 { public static void main(String[] args) { int j=2, i=5; while( j<i--) j++; System.out.println(j); } }
A.3
B.2
C.4
D.5
第19题:
以下程序运行后输出的结果是______。
public class exl7
{
public static void main(String args [])
{
int a = 0;
for(int j = 1; j <= 20; j++)
if(j%5 != 0)
a = a + j;
System.out.println (a);
第20题:
有如下程序 public class Sun { public static void main(String args[ ]) { int x=1,a=0,b=0; switch(x) { case 0:b++; case 1:a++; case 2: a++; b++; } System.out.println("a="+a+","+"b="+B) ; } } 该程序的输出结果是( )。
A.a=2,b=1
B.a=1,b=1
C.a=1,b=0
D.a=0,b=0
第21题:
public class SwitchTest { public static void main(String[] args) { System.out.println(“value = “ + switchIt(4)); } public static int switchIt(int x) { int j = 1; switch (x) { case 1: j++; case 2: j++; case 3: j++; case 4: j++; case 5: j++; default: j++; } return j + x; } } What is the result?()
第22题:
public class SwitchTest { public static void main (String args) { System.out.PrintIn(“value =” +switchIt(4)); } public static int switchIt(int x) { int j = 1; switch (x) { case 1: j++; case 2: j++; case 3: j++; case 4: j++; case 5: j++; default:j++; } return j + x; } } What is the output from line 3? ()
第23题:
Value = 3
Value = 4
Value = 5
Value = 6
Value = 7
Value = 8
第24题:
Value = 3
Value = 4
Value = 5
Value = 6
Value = 7
Value = 8