首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
下面程序的输出结果是( )。 public class Sun { public static void main(String args[ ]) { int[] a=new int[1
下面程序的输出结果是( )。 public class Sun { public static void main(String args[ ]) { int[] a=new int[1
admin
2010-07-28
26
问题
下面程序的输出结果是( )。 public class Sun { public static void main(String args[ ]) { int[] a=new int[11]; int[] p=new int[4]; int k=5; for (int i=1; i<=10; i++) a
=i; for(int i=1;i<=3;i++) p
=a[i*i]; for (int i=1; i<=3;i++) k=k+p
*2; System.out.println (k); } }
选项
A、33
B、28
C、35
D、37
答案
1
解析
本题考查对for循环语句和数组的理解。此题中共定义了两个数组,a[]p[]共用了3次for循环。第1个for语句对数组 a
赋值,a[1]...a[10]=1...10:第2个for语句,对数组p
赋值p[1]=1,p[2]=4,p[3]=9;第3个for语句,计算k的值。3次循环分别得到:5、15、33。故本题答案是A。
转载请注明原文地址:https://jikaoti.com/ti/w8H0FFFM
本试题收录于:
二级Java题库NCRE全国计算机二级分类
0
二级Java
NCRE全国计算机二级
相关试题推荐
下列叙述中,不属于测试的特征的是()。
软件工程的出现是由于()。
在下列链表中,能够从任意一个结点出发直接访问到所有结点的是
在深度为5的满二叉树中,叶子结点的个数为
下面叙述中正确的是
负责数据库中查询操作的数据库语言是
结构化程序设计中,下面对GOTO语句使用描述正确的是
给出如下代码:TempStr=’’HelloWorld’’以下选项中可以输出“World”子串的是
索引属于______。
一个应用程序必须继承Canvas类才能获得有用的功能,比如创建一个自定义构件。如果想在画布上完成一些图形处理,则Canvas类中的哪个方法必须重写?
随机试题
DNA复制时不需要的酶是
关于头颅扫描基线的叙述,正确的是
关于流行性出血热患者,错误的处理是
以下关于开发区区域环境影响评价实施方案说法正确的有()。
由建设单位主持,主要检查施工合同执行情况和监理工作情况,提出工程质量等级称为()。
对于进出口货物收发货人的报关行为规则,以下表述正确的是;
东北三宝指的是人参、貂皮和鹿茸。()
皮亚杰把人的认识发展划分为不同的阶段,下列属于形式运算阶段的心理特点的有()
中共七大总结历史经验,将党在长期奋斗中形成的优良传统作风概括为三大作风,分别是()。
教育学作为一门课程在大学讲授始于()
最新回复
(
0
)