首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
阅读下列代码后 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
30
问题
阅读下列代码后 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://jikaoti.com/ti/C1H0FFFM
本试题收录于:
二级Java题库NCRE全国计算机二级分类
0
二级Java
NCRE全国计算机二级
相关试题推荐
在长度为64有序线性表中进行顺序查找,最坏情况下需要比较的次数为
下面描述中,不属于软件危机表现的是
设某棵树的度为3,其中度为3、2、1的结点个数分别为3、0、4。则该树中的叶子结点数为
设二叉树T的深度为4,其中度为1,2,3,4的结点个数分别为4,2,1,1。则T中的叶子结点数为
定义学生选修课程的关系模式:SC(S#,Sn,C#,Cn,G)(其属性分别为学号、姓名、课程号、课程名、成绩)。则对主属性部分依赖的是
如下是一个完整程序,请补充横线处代码,输出如“2020年10月10日10时10分10秒”样式的时间信息。①timestr=’’2020-10-1010:10:10’’t=time.strptime(timestr,’’%Y一%m一%d%H:%M:%
关于Python语句P=-P,以下选项中描述正确的是
下面关于类的说法错误的是()。
选择正确的语句填入下列程序的横线处。importjava.awt.*;importjava.awt.event.*;publicclassex21{staticFramef;
给出下列的程序段,则哪个选项是类A合理的内部类?()classA{protectedinti;A(inti){this.i=i;
随机试题
经皮肤黏膜吸收毒物而中毒的患者,下列清洗皮肤的措施,哪项有错误
甲状腺功能亢进时.腹泻的主要发生机制是
手太阳经分布在()
黄某因在石家庄市诈骗,被裕华区公安机关抓获,下列说法不正确的有()
所有项目内非营业性配套设施费用可直接计入开发项目成本。()
建造桥梁取得的收入属于()。
税务行政复议中的被申请人是指()。
下列收入中,应依法征收城建税的是( )。
固定资产原值的确定原则不包括()。
A)Dinosaurs,StarWars,trainschedules,Disneyprincesses,maps,LEGO—subjectssuchasthesecanbecomeall-consumingpassions
最新回复
(
0
)