首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
阅读下列代码后 public class Person{ int arr[]=new int[10]; public static void main(String args[]){ System.out.print
阅读下列代码后 public class Person{ int arr[]=new int[10]; public static void main(String args[]){ System.out.print
admin
2010-07-28
21
问题
阅读下列代码后 public class Person{ int arr[]=new int[10]; public static void main(String args[]){ System.out.println(arr[1]); } } 正确的说法是( )。
选项
A、编译时将产生错误
B、编译时正确,运行时将产生错误
C、输出零
D、输出空
答案
1
解析
本题考查考生对Java中数组的定义及使用。int arr[]=new int[10]表示数组arr是一个含有10个元素的整数数组。Java中的数据类型必须实例化后才能使用,但是有种情况例外,就是该成员是用static声明的。题目中对于数组并没有实例化,因此不能使用,所以选项A说法正确。如果加上static修饰符,改为 static int arr[]=new int[10]或者将该数组实例化即可,输出为0。
转载请注明原文地址:https://kaotiyun.com/show/yH9p777K
本试题收录于:
二级Java题库NCRE全国计算机二级分类
0
二级Java
NCRE全国计算机二级
相关试题推荐
下列叙述中正确的是
程序流程图中带有箭头的线段表示的是
下列关于数据库设计的叙述中,正确的是
用树形结构表示实体之间联系的模型是
软件(程序)调试的任务是()。
在软件生命周期中,能准确确定软件系统必须做什么和必须具备哪些功能的阶段是
关于Python程序格式框架的描述,以下选项中错误的是
软件设计包括软件的结构、数据接口和过程设计,下列选项中属于软件的过程设计的是
设栈的存储空间为s(1:m),初始状态为top=m+1。经过一系列入栈与出栈操作后,top=1。现又要将一个元素入栈,栈顶指针top值变为()。
标识符是以______、下划线(__)、美元符($)作为首字母的字符串序列。
随机试题
下列关于常山的叙述中,正确的是
对预期取得的收入和支出所进行的计划工作是
可出现飞蚊症的有()
A.系统性红斑狼疮B.白塞病C.显微镜下多血管炎D.原发性干燥综合征E.系统性硬化病
土钉墙施工时,垫板与喷混凝土面层间的空隙应用()填平。
公司举办开放参观活动,赠送的纪念品可以是()。
文艺复兴时期的美术使意大利美术达到光辉灿烂的鼎盛时期,其中出现三位著名画家,被称为“文艺复兴三杰”,有关其论述正确的是()
供给侧结构性改革的主攻方向是()
IwasintroducedtotheconceptofliteracyanimatorinOladumiArigbede’s(1994)articleonhighilliteracyratesamongwomena
COALESCE:
最新回复
(
0
)