首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
阅读下列代码后 public class Person{ int arr[]=new int[10]; public static void main(String args[]){ System.out.pr
阅读下列代码后 public class Person{ int arr[]=new int[10]; public static void main(String args[]){ System.out.pr
admin
2010-12-17
29
问题
阅读下列代码后 public class Person{ int arr[]=new int[10]; public static void main(String args[]){ System.out.println(arr[1]); } } 正确的说法是
选项
A、编译时将产生错误
B、编译时正确,运行时将产生错误
C、输出零
D、输出空
答案
A
解析
本题考查考生对Java中数组的定义及使用。int arr[]=new int[10]表示数组 arr是一个含有10个元素的整数数组。Java中的数据类型必须实例化后才能使用,但是有种情况例外,就是该成员是用static声明的。题目中对于数组并没有实例化,因此不能使用,所以选项A说法正确。如果加上static修饰符,改为static int arr[]=new int[10]或者将该数组实例化即可,输出为0。
转载请注明原文地址:https://kaotiyun.com/show/SM9p777K
本试题收录于:
二级Java题库NCRE全国计算机二级分类
0
二级Java
NCRE全国计算机二级
相关试题推荐
下列叙述中正确的是
在数据管理技术发展的三个阶段中,数据共享最好的是
设表的长度为n。在下列算法中,最坏情况下时间复杂度最高的是
在结构化程序设计中,模块划分的原则是
下面属于整数类I实例的是
执行如下代码:importturtleastforiinrange(1,5):t.fd(50)t.left(90)在PythonTurtleGraphics中,绘制的是
下面代码的输出结果是print(0.1+0.2==0.3)
给标识符关联名字的过程是
选择正确的语句填入下列程序的横线处。importjava.awt.*;importjava.awt.event.*;publicclassex21{staticFramef;
能将程序补充完整的选项是classPerson{privateinta;publicintchange(intm){returnm;}}publicclassTeacherex
随机试题
患者,女,60岁。反复发作胸闷胸痛半月余,痰多白粘,纳呆,脘胀,形寒肢冷,舌苔白腻,脉弦滑。心电图V3、V4、V5、V6导联ST段下移,T波倒置。其证型是
房地产市场细分的依据主要有()。
下列关于投资项目财务分析中利息备付率和偿债备付率两个指标的表述,正确的是()。
剪力墙体系足利用建筑物的墙体(内墙和外墙)做成剪力墙来抵抗水平力。适用于小开间的住宅和旅馆等。剪力墙一般为钢筋混凝土墙,剪力墙的厚度和间距一般为()。
下列关于税款受偿顺序的说法中,正确的有()。
某投资方案,当贴现率为16%时其净现值为38万元,当贴现率为18%时其净现值为一22万元。该方案的内部收益率是()。
海浪水泥公司成立于1997年,主要从事水泥及其熟料的生产和销售,2002年2月成功上市。海浪水泥总部坐落于A省。A省是全国水泥生产主要原材料石灰石储量第二大的省份,且石灰石质量较高。海浪水泥凭借先天条件坐拥原材料成本和质量优势。水泥产品体积大、单
a>2,则双曲线的离心率的取值范围是()。
Justgivingoutcashtopoorpeopleisaprettygoodwaytomakethemlesspoor.Thatmightseemobvious,butitwasn’tacommon
可导函数y=f(x)由方程x3-3xy2+2y3=32所确定,试求f(x)的极大值与极小值.
最新回复
(
0
)