3在下面的代码中: publicclassTest{publicstaticvoidmain(String[]args){inti=20;setValue(i);System.out.println(“i=”+i);}staticvoidsetValue(inti){i=i+1;}} 变量i的值最终输出为多少?
A: 20
B: 21
C: 22
D: 23
A: 20
B: 21
C: 22
D: 23
举一反三
- 请阅读下面的程序,sum的值为()publicclassTest{publicstaticvoidmain(String[]args){intsum=0;for(inti=1;i=100;i++){if(i%2==1){continue;}sum+=i;}System.out.println(sum=+sum);}}
- 下列程序编译并运行的结果为()publicclassTest{publicstaticvoidmain(String[]args){try{inti=1;System.out.println(i++);}finally{System.out.println(++i);}}}
- 下面代码的运行结果是_____________。publicclassTest{publicstaticvoidmain(String[]args){int[]a=newint[3];int[]b=newint[]{1,2,3,4,5};a=b;for(inti=0;i<;b.length;i++){System.out.print(a[i]+"");}}}[/i] A: 程序报错 B: 123 C: 12345 D: 000
- 以下代码的输出结果是_________。publicstaticvoidmain(String[]args){for(inti=1;i<;=10;i++){if(i%2==0||i%5==0){continue;}System.out.print(i+"\t");}} A: 1 B: 134 C: 13579 D: 1379
- 阅读下面的代码,输出结果是 publicstaticvoidmain(String[]args){ Randomrandom1=newRandom(10); Randomrandom2=newRandom(10); for(inti=0;i<5;i++){ System.out.print(random1.nextInt(5)); } System.out.println(); for(inti=0;i<5;i++){ System.out.print(random2.nextInt(5)); } }