首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
执行下列程序段后输出的结果是______。 public class Test{ public static void main(String args[]){ int x,y; for(y=1,x=1;y<=50;y++){ if(x>=10)break
执行下列程序段后输出的结果是______。 public class Test{ public static void main(String args[]){ int x,y; for(y=1,x=1;y<=50;y++){ if(x>=10)break
admin
2012-12-13
30
问题
执行下列程序段后输出的结果是______。
public class Test{
public static void main(String args[]){
int x,y;
for(y=1,x=1;y<=50;y++){
if(x>=10)break;
if (x%2==1){
x+=5;
continue;
}
x-=2;
}
System.out.println(y);
}
}
选项
答案
6
解析
本题是对for循环和if条件语句的综合考查。当y=1,x=1时不满足第1个 if语句,向下继续执行第2个if语句x=6,继续执行 for循环;当y=2,x=6时,不满足第1个和第2个 if语句,x=3,继续执行for循环;当y=3,x=3时,不满足第1个if语句,向下继续执行第2个if语句 x=8,继续执行for循环;一直执行下去,直到y=6, x=12时满足第1个if语句,退出for循环。
转载请注明原文地址:https://kaotiyun.com/show/e22p777K
本试题收录于:
二级Java题库NCRE全国计算机二级分类
0
二级Java
NCRE全国计算机二级
相关试题推荐
关于赋值语句,以下选项中描述错误的是
在Python吾言中,不能作为变量名的是()。
以下描述错误的是()。
在Python语言中,可以作为源文件后缀名的是()。
以下关于Python字典变量的定义中,正确的是()。
循环队列的存储空间为Q(1:50)。经过一系列正常的入队与退队操作后,front=rear=25。后又成功地将一个元素退队,此时队列中的元素个数为()。
设栈与队列初始状态为空。将元素A,B,C,D,E,F,G,H依次轮流入栈和入队,然后依次轮流退队和出栈,则输出序列为()。
关系数据模型的三个组成部分中不包括()。
关于数据库管理阶段的特点,下列说法中错误的是()。
如果有一个类MyFrame是Frame的子类,能够被不同包中的类所使用,请写出该类的声明头:【】。
随机试题
TheName"UnitedNations"Thename"UnitedNations"was【C1】______(probable)devisedbyU.S.【C2】______(preside)FranklinD.
为防止原文档损坏,Excel2010提供创建文档的备份副本的策略,可在每次保存文件时生成一个扩展名为wbk的副本文件。
“文章的布局也就是一种阵势,每一段就是一个队伍,摆在最得力的地位才可以发生最大效用”,这句话的修辞方法是
下列关于溃疡性结肠炎的肠外表现中,随肠炎控制或结肠切除后可以缓解或恢复的是
下列关于尸检说法错误的是
患者男性,36岁,工人,在车间工作时被机器扎伤右前臂来急诊。注射破伤风抗毒素预防破伤风的机制是
孙某的以下行为,行为无效的是?
某施工单位承包了一项通信局站的电源系统安装工程,施工单位编制了施工组织计划,其中资源配备计划包括机具及仪表使用计划、材料需求计划;电源系统的接地系统有交流接地系统、工作接地系统、保护接地系统和防雷接地系统。工程完工后,施工单位编制了竣工材料,包括竣工图、
个人所购商用房为商住两用房的,贷款额度不得超过所购商用房价值的()。
设函数z=f(x,y)在点(1,1)处可微,且f(1,1)=1,φ(x)=f(x,f(x,x)).求φ3(3)|x=1.
最新回复
(
0
)