首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有下面程序段: Public class ArrayTest { Public static void main(String args[]) { int[] intArray=new int[3
有下面程序段: Public class ArrayTest { Public static void main(String args[]) { int[] intArray=new int[3
admin
2010-02-22
34
问题
有下面程序段: Public class ArrayTest { Public static void main(String args[]) { int[] intArray=new int[3]; for(int I=0;I<3;I++) { intArray[I]=I+2; System.out.println("IntArray["+I+"]"-"+intArray[I]); } System.out.println("------------"); Int arrLen=4; IntArray=new int[arrLen]; For(int j=intArray.length;j>=0;j--} { intArray [j]=j*3; System.out.println("hello"+intArray[j]); } } } 则运行的结果是( )。
选项
A、编译出错
B、编译通过,但运行出错
C、可以运行,但有错误
D、以上都不对
答案
2
解析
这是一道考查数组引用的题,目的是考查如何在程序中引用初始化后的数组。引用的方式为arrayName[index),其中index为数组的下标,可以为整数、变量和表达式,范围从0开始,一直到数组的长度减1。在Java语言中,是要对数组下标进行检查的。因此当程序运行到数组的长度值时,就发生了越界现象。
转载请注明原文地址:https://kaotiyun.com/show/469p777K
本试题收录于:
二级Java题库NCRE全国计算机二级分类
0
二级Java
NCRE全国计算机二级
相关试题推荐
在关系模型中,把数据看成一个二维表,每一个二维表称为一个()。
软件设计包括软件的结构、数据接口和过程设计,其中软件的过程设计是指______。
用树型结构表示实体类型及实体间联系的数据模型称为()。
长度为n的顺序存储线性表中,当在任何位置上插入一个元素概率都相等时,插入一个元素所需移动元素的平均个数为()。
数据结构作为计算机的一门学科,主要研究数据的逻辑结构、对各种数据结构进行的运算,以及______。
当线性表采用顺序存储结构实现存储时,其主要特点是()。
定义无符号整数类为UInt,下面可以作为类UInt实例化值的是
有两个关系R和S如下:则由关系R得到关系S的操作是()。
负责数据库中查询操作的数据库语言是()。
下面关于Python中函数参数的说法错误的是()。
随机试题
中庸之道
下列列强中,发动并参加第一次鸦片战争、第二次鸦片战争和八国联军侵华战争的是()。
函数z=xy(9一x—y)的极值点是_________.
α-HBDH测定实际反映的主要是下列哪种酶的活性
下列()项应逐桩检验孔底尺寸和岩土情况。
施工机械使用费的索赔包括()
浦江麦秆剪贴又称“麦秆画”、“麦秆剪贴画”等。下列有关浦江麦秆剪贴的正确表述有()。
行政处罚是指行政机关依法对违反行政管理秩序的公民、法人或其他组织给予制裁的行政行为。据此,下列属于“行政处罚”的是:
下列选项中,属于人的担保方式的是
The"dawnofthedemocratizationoftheTVandfilmbusiness"probablymeans______.Thepurposeofthistextisprimarilyto_
最新回复
(
0
)