18、下列代码运行时会产生()类型的异常。 int[] array = new int[4]; System.out.println(array[7]);A.ArithmeticExceptionB.ArrayIndexOutOfBoundsExceptionC.ClassCastExceptionD.NullPointerException

18、下列代码运行时会产生()类型的异常。 int[] array = new int[4]; System.out.println(array[7]);

A.ArithmeticException

B.ArrayIndexOutOfBoundsException

C.ClassCastException

D.NullPointerException


参考答案和解析
ArrayIndexOutOfBoundsException

相关考题:

下面的PHP程序运行的结果是什么?( )?phpfunction sort_my_array(}$a1 = array(3,2,1);var_dump(sort_my_array($a1)); A.NULLB.array(3){[0]=int(1) [1]=int(2) [2]=int(2)}C.bool(true)D.array(3){[2]=int(1) [1]=int(2) [0]=int(3)}

int[]my_Array;my_Array=newint[5];for(intcount=0;count=5;count++)System.out.println(my_Array[count]);以上Java代码运行的结果是()。 A.将1,2,3,4,5输出到屏幕B.将0,1,2,3,4输出到屏幕C.将0,1,2,3,4,5输出到屏幕D.将出现运行时异常

int[]my_Array;my_Array=newint[5];for(intcount=0;count=5;count++)System.out.println(my_Array[count]);结果是() A.将1,2,3,4,5输出到屏幕B.将0,1,2,3,4输出到屏幕C.将0,1,2,3,4,5输出到屏幕D.将出现运行时异常

在下述Java语言语句中,错误的创建数组的方法是()A.int int Array[];int Array=new int[5];B.int int Array[]=new int[5];C.int[]int Array={1,2,3,4,5};D.int int Array[5]={1,2,3,4.5};

已有如下数组定义和f函数调用语句,则在f函数的说明中,对形参数组array的正确定义方式为int a[3][4];f(a);A.f(array[3][4])B.f(int array[3][])C.f(int array[][4])D.f(int array[][])

下列数组a中,版本较新的能在程序运行时动态调整大小的是A.int a[]B.String []aC.a=new ArrayList()D.a=new Array()

下列数组定义及赋值,错误的是( )。A.int a[]={1,2,3,4,5};B.int intArray[];C.int Array=new int[3]; int Array[1]=1; int Array[2]=2; int Array[3]=3;D.int a[][]=new int[2][]; a[0]=new int[3]; a[1]=new int[3];

C语言数组输出间隔 #include stdio.hvoid main(){ void sort(int array[],int n); int a[10],i; printf("enter the array:\n"); for(i=0;i10;i++) scanf("%d", sort(a,10); printf("The sorted array:\n"); for(i=0;i10;i++) printf("%d",a[i]); printf("\n");}void sort(int array[],int n){ int i,j,k,t; for(i=0;in-1;i++) { k=i; for(j=i+1;jn;j++) if(array[j]array[k]) k=j; t=array[k];array[k]=array[i];array[i]=t; }}程序呢,就是这个了。谭老爷子书上的例题,和书上一样,然后输入:5 7 -3 21 -43 67 321 33 51 0 然后从小到大排好后输出,书上他们之间从小到大有间隔,但是我运行了,没有间隔。。。。( ⊙o⊙ )?咋解决?????来高手解答。。。我运行后是:-43-305721335167321

有以下程序: include include usingnamespacestd; intmain() {intarrays 有以下程序: #include <iostream> #include <cstdlib> using namespace std; int main() { int arraysize; int *array; cout<<"Please input the size of the array:"; cin>>arraySiZe; array=new int[arraysize]; if(array==NULL) { cout<<"allocate Error\n"; exit(1); } for(int i=0;i<arraysize;i++) array[i]=i*i; int j; cout<<"which element you want to check:"; cin>>j; cout<<array[j]<<end1; return 0; } 执行程序输入:10<空格>5,则输出结果为( )。A.allocate ErrorB.1C.0D.25

下列数组array_test中,能在程序运行时动态调整大小的是A.int array_test[]=new int[10]B.String[] array_testC.ArrayList army_test=new Array List()D.Array array_test=new Array()

阅读以下说明及C++程序代码,将应填入(n)处的语句写在对应栏内。【说明】本程序的功能是生成螺旋方阵,用户可以输入该方阵的行列数,然后就生成对应的螺旋方阵。例如:当n=5时,对应的螺旋方阵如下:1 16 15 14 132 17 24 23 123 18 25 22 114 19 20 21 105 6 7 8 9【C++代码】include"stdio.h"include"iostream,h"int array[11][11];int temp;int ROW;void godown(int m,int a){for(temp=1; temp<=ROW;temp++)if(array[temp][a]==0)array[temp][a]=(1);a++;}void goright(int m,int b){for(temp=1;temp<=ROW;temp++)if(array[b][temp]==0)array[b][temp]=m++;b--;}void goup(int m.int c){for(temp=ROW;temp>0;temp-)if(array[temp][c]==0)array[temp][c]=m++;c--;}void goleft(int m,int d){for(temp=ROW;temp>0;temp--)if(array[d][temp]==0)array[d][temp]=m++;(2);}void main(){int a,b,c,d,max,m;cin>>ROW;cout>>end1;for(a=1;a<=ROW;a++)for(b=1;b<=ROW;b++)(3);m=1;a=d=1;b=c=ROW;max=(4);whiie(m<=max){godown(m,a);(5) (m,b);goup(m,c);goleft(m,d):}for(a=1;a<=ROW;a++){for(b=1;b<=ROW;b++)printf("%3d ",array[a][b]);cout<<end1;}}

下列程序用于打印出ASCⅡ字符,其析构函数内的语句应为【 】。 include inelude 下列程序用于打印出ASCⅡ字符,其析构函数内的语句应为【 】。include<iostream. h>inelude<iomanip, h>template<class T>class Array{T * elems;int size;public:Array(int.s);~Array()T operator[](int)void perator=(T)};template<class T>Array<T>::Array(int s)size=s;elems=new T[size]for(int i=0;i<size;i++)elems[i]=0}template<celass T>Array<T>::~Array(){______template <class T>T Array<T>::operator[](int index){return elems[index];}template<class T>void Array<T>::operator=(T temp){for(int i=0;i<size;i++)elems[i]=temp;}void main(){int i,n=26;Array<int> arr1(n)Array<char> arr2(n)for(i=0;i<n;i++){ -.arr1[i]='a'+i;arr2[i]='a'+i;}cout<<"ASCII 字符"<<endl;for(i=0;i<n;i++)cout<<setw(8)<<arr1[i]<<setw(8)<<arr2[i]<<endl;}

下列数组说明中,正确的是______。A.int array[][4];B.int array[][];C.int marray[][][5];D.int array[3][];

下列程序的输出结果是( )。 Public class Test{ Public static void main(String[]args){ int[]array=(2,4,6,8,10); int size=6; int result=-l: try{ for(int i=0;isizeresult= =-1:) if(array[i]= =20)result=i: } catch(ArithmeticException e){ System.out.println("Catch---1"); } catch(ArraylndexOutOfBoundsException e){ System.out.println("Catch---2"): } catch(Exception e){ System.out.println("Catch---3"): } }A.Catch---1B.Catch---2C.Catch---3D.以上都不对

下列程序的输出结果是( )。 public class Test{ public static void main(String[]args){ int[]array=(2,4,6,8,lO); int size=6; int result =-1: try{ for(int i=0;i(size 8Lresult= = -1;) if(array[i]= =20)result=i: } catch(ArithmeticException e){ System.out.println("Catch- - -l"); } catch(ArraylndexOutOfBoundsException e){ System.out.println("Catch- - -2"); } catch(Exception e){ System.out.println("Catch- - -3");) } }A.Catch- - -1B.Catch- - -2C.Catch- - -3D.以上都不对

下列数组定义与其他一致的是?()A、vala=Array[Int](0,0)B、vala=Array(0,0)C、vala=newArray[Int](2)D、vala=Array[Int](1,1)

int [] my_Array;  my_Array = new int[5];  for(int count = 0; count = 5; count++)  System.out.println(my_Array[count]); 结果是()A、将1,2,3,4,5输出到屏幕B、将0,1,2,3,4输出到屏幕C、将0,1,2,3,4,5输出到屏幕D、将出现运行时异常

You need to create a JSP that generates some JavaScript code to populate an array of strings used on theclient-side. Which JSP code snippet will create this array?()A、MY_ARRAY = new Array();% for ( int i = 0; i  serverArray.length; i++ ) { MY_ARRAY[%= i %] = ’%= serverArray[i] %’;} %B、MY_ARRAY = new Array();. % for ( int i = 0; i  serverArray.length; i++ ) { . MY_ARRAY[${i}] = ’${serverArray[i]}’;. } %C、MY_ARRAY = new Array();. % for ( int i = 0; i  serverArray.length; i++ ) { % . MY_ARRAY[%= i %] = ’%= serverArray[i] %’;. % } %D、MY_ARRAY = new Array();% for ( int i = 0; i  serverArray.length; i++ ) { % . MY_ARRAY[${i}] = ’${serverArray[i]}’;. % } %

int[]my_Array; my_Array=newint[5]; for(intcount=0;count=5;count++)System.out.println(my_Array[count]); 以上Java代码运行的结果是()。A、将1,2,3,4,5输出到屏幕B、将0,1,2,3,4输出到屏幕C、将0,1,2,3,4,5输出到屏幕D、将出现运行时异常

下面哪条语句定义了5个元素的数组()。A、int[]a={22,23,24,25,12};B、int a[]=new int(5);C、int[5]array;D、int[]arr;

int intArray[]={0,2,4,6,8}; int length=int Array.length()。

Which two create an instance of an array?() A、 int ia = new int [15];B、 float fa = new float [20];C、 char ca = “Some String”;D、 Object oa = new float[20];E、 Int ia = (4, 5, 6) (1, 2, 3)

假设调用函数有以下定义和函数f调用,则函数f中对形参数组错误定义的是()。 charc[5]={‘a’,’b’,’0’,’c,’0’}; printf(“%s”,c);A、f(int array[][6])B、f(int array[3][])C、f(int array[][4])D、f(int array[2][5])

对数组的定义及初始化不正确的方法是:()。A、int array[];B、int array[8];C、int[]array=new int[8];D、int array[]=new int[8];

单选题对数组的定义及初始化不正确的方法是:()。Aint array[];Bint array[8];Cint[]array=new int[8];Dint array[]=new int[8];

单选题int [] my_Array;   My_Array=new int [5];   For(int count = 0 ;  count =5; count ++)    System.out.pringtln(my_Array[count]);   以上Java代码运行的结果是()A将1,2,3,4,5输出到屏幕B将0,1,2,3,4输出到屏幕C将0,1,2,3,4,5输出到屏幕D将出现运行时异常

单选题有如下程序:#include int sum(int *array,int len){ if(len == 0)  return array[0]; else  return array[0]+sum(array+1,len-1);}main(){ int array[5] = {1,2,3,4,5}; int res = sum(array,4); printf(%d,res);}程序运行后的输出结果是(  )。A15B10C8D1

单选题有如下程序:#include struct pair{ int first,second;};struct pair get_min_max(int*array, int len){ int i; struct pair res; res.first=array[0]; res.second=array[0]; for(i=1;ires.second)   res.second=array[i]; } return res;}main(){ int array[5]={9,1,3,4}; struct pair min_max = get_min_max(array,5); printf(min=%d,max=%d, min_max.first, min_max.second);}程序运行后的输出结果是(  )。Amin=1,max=9Bmin=0,max=9Cmin=1,max=4Dmin=0,max=4