问题 单项选择题

下面程序段的输出结果是( )。 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。

多项选择题 案例分析题
单项选择题