万能百科  > 计算机   > 

[单项选择题] 下面程序段的输出结果是( )。 public class Test public static void main (String[) ar

2021-07-20   

[单项选择题] 下面程序段的输出结果是( )。

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。

词条内容仅供参考,如果您需要解决具体问题
(尤其在法律、医学等领域),建议您咨询相关领域专业人士。

标签