题目内容

现有:class TestApp {public static void main(String[] args) {int[] myarray = { 10, 11, 12, 13, 14 };int sum = 0;for (int x : myarray)sum += x;System.out.println("sum= " + sum);}}上述程序运行后的结果是哪项?

A. sum=10
B. sum=70
C. sum=60
D. 运行时抛出异常

查看答案
更多问题

现有:class WhileTests {public static void main(String[] args) {int x = 5;while (++x < 4) {--x;}System.out.println("x=" + x);}}结果是什么?

A. x=6
B. x=5
C. x=2
D. 编译失败

现有:class Foo {public static void main(String[] args) {int x = 0;int y = 4;for (int z = 0; z < 3; z++, x++) {if (x > 1 & ++y < 10)y++;}System.out.println(y);}}结果是什么?

A. 7
B. 8
C. 10
D. 12

int i=1 , j=10;do{if(i>j)continue;j--;}while(++i<6);经过上面的代码后,i和j的值是多少?( )

A. i=6,j=5
B. i=5,j=5
C. i=6,j=4
D. i=5,j=6

What will be the value of x after the following code is executed?执行以下代码后,x的值是多少?int x = 10, y = 20;while (y < 100){x += y;}

A. 90
B. 110
C. 210
D. This is an infinite loop 这是一个死循环/无限循环

答案查题题库