首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
阅读下列代码后public class Person{ int arr[]=new int[10]; public static void main(String args[]){ System.out.println(arr[1]); }}正
阅读下列代码后public class Person{ int arr[]=new int[10]; public static void main(String args[]){ System.out.println(arr[1]); }}正
admin
2009-02-10
32
问题
阅读下列代码后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/EDnp777K
本试题收录于:
二级Java题库NCRE全国计算机二级分类
0
二级Java
NCRE全国计算机二级
相关试题推荐
以下叙述错误的是()。
(1)打开“订货管理”数据库,并将表order-list添加到该数据库中。(2)在“订货管理”数据库中建立表order_detail,表结构描述如下:订单号字符型(6)器件号字符型(6)器件名字符型(16)单价浮
在考生文件夹下完成下列操作:为了查询不同歌手演唱的歌曲,请设计一个表单mform.scx,其界面如图3-14所示。表单控件名为formone,表单的标题为“歌曲查询”。表单左侧有一个标签控件Labelone,显示内容为“输入歌手姓名”,一个文本框控件
数据库设计中反映用户对数据要求的模式是
下列描述中错误的是
将自由表“外汇汇率”、“外汇账户”、“外汇代码”加入到新建的“外汇”数据库中。
关于内存变量的调用,下列说法错误的是()。
当数据的物理结构(存储结构、存取方式等)改变时,不影响数据库的逻辑结构,从而不致引起应用程序的变化,这是指数据的
根据输入字符串s,输出一个宽度为15字符,字符串s居中显示,以“=”填充的格式。如果输入字符串超过15个字符,则输出字符串前15个字符。例如:输入字符串s为’’PYTHON’’,则输出“=====PYTHON====”。s=input(’’请输入一个字符
继承是Java语言的一个重要机制,所有的Java类都继承自根类()。
随机试题
修后热工仪表准确率为()。
欧洲文学史上最早反映劳资矛盾的作家是
导致泄泻发生的关键病理因素是
代表口腔卫生指数的是
基本建设单位和从事建筑安装业务的企业附设的工厂、车间在建筑现场制造的预制构件,凡直接用于本单位或本企业建筑工程的,不征收增值税。()
甲股份有限公司(以下简称甲公司)为上市公司,是增值税一般纳税企业,适用的增值税税率为17%,按资产负债表债务法核算企业所得税,适用的所得税税率为25%;甲公司20×7年度净利润为40000万元,假设20×7年所得税汇算清缴在20×8年4月30日完成。20×
甲公司2013年至2018年发生以下交易或事项:2013年12月31日购入一栋办公楼,实际取得成本为6000万元。该办公楼预计使用年限为20年,预计净残值为零,采用年限平均法计提折旧。因公司迁址,2016年6月30日甲公司与乙公司签订租赁协议。该协议约定
Duringthesummerholiday,IthinkIshoulddosomething【M1】______meaningfulinsteadtouring.SoIgotajo
我们的身体里有着以各种形式存在的能量,科学家们也一直在思考用人体给可穿戴设备供电的方法,中美研究团队2013年发明了依靠运动动能发电的压电纤维,来自澳大利亚和中国的研究人员在2015年首次成功开发了能将热能转化为电能的新型面料,乍看起来,眼泪似乎是比汗水更
Weoftenreadinnovelshowaseeminglyrespectablepersonorfamilyhassometerriblesecretwhichhasbeenconcealedfromstr
最新回复
(
0
)