下面程序段的输出结果是(  )。 public class Test { public static void main (String[) args) { int a,b; for(a=1,

admin2012-12-13  28

问题 下面程序段的输出结果是(  )。    public class Test {        public static void main (String[) args) {            int a,b;            for(a=1,b=1;a<=100;a++) {                if (a>=10 ) break;                if (b%2==1) {                    b+=2;                    continue;                }            }            System. out. pdntln(A);        }    }

选项 A、7
B、8
C、9
D、10

答案D

解析 虽然程序中的for循环是变量a从1到100,但程序中a=10时,遇到break语句,退出循环,所以退出循环后a=10,选择D。
转载请注明原文地址:https://jikaoti.com/ti/AK80FFFM
0

最新回复(0)