网友您好, 请在下方输入框内输入要搜索的题目:
题目内容
(请给出正确答案)
单选题
在Java语言中,在程序运行时会自动检查数组的下标是否越界,如果越界,会抛掷下面的()异常。
A
NullpointerException
B
ArithmeticExceptioin
C
ArrayIndexOutOfBoundsException
D
SecurityManager
参考答案
参考解析
解析:
暂无解析
更多 “单选题在Java语言中,在程序运行时会自动检查数组的下标是否越界,如果越界,会抛掷下面的()异常。A NullpointerExceptionB ArithmeticExceptioinC ArrayIndexOutOfBoundsExceptionD SecurityManager” 相关考题
考题
下列常见的系统定义的异常中,() 是数组下标越界异常。
A.ArithmeticExceptionB.IOExceptionC.ArrayIndexOutOfBoundsExceptionD.NullPointerException
考题
研究下面的Java代码:publicclasstestException{publicstaticvoidmain(Stringargs[]){inta[]={0,1,2,3,4};intsum=0;try{for(inti=1;i6;i++)sum=sum+a[i];System.out.println(sum=+sum);}catch(ArrayIndexOutOfBoundsException){System.out.println(数组越界);}finally{System.out.println(程序结束);}}}输出结果将是()。A.10数组越界程序结束B.10程序结束C.数组越界程序结束D.程序结束
考题
在Java语言中,在程序运行时会自动检查数组的下标是否越界,如果越界,会抛掷下面的()异常。
A.NullpointerExceptionB.ArithmeticExceptioinC.ArrayIndexOutOfBoundsExceptionD.SecurityManager
考题
阅读以下程序说明和C++程序,将程序段中(1)~(5)空缺处的语句填写完整。[说明]C++语言本身不提供对数组下标越界的判断。为了解决这一问题,在以下[C++程序]中定义了相应的类模板,使得对于任意类型的二维数组,可以在访问数组元素的同时,对行下标和列下标进行越界判断,并给出相应的提示信息。[C++程序]include <iostream.h>template <class T> class Array;template <Class T> class ArrayBody {friend (1);T* tpBody;int iRows,iColumns, iCurrentRow;ArrayBody(int IRsz, int iCsz) {tpBody =(2);iRows = iRsz;iColumns = iCsz;iCurrentRow = -1;}Public:T operator[] (int j) {bool row_error, column_error;row_error = column_error =false;try {if (iCurrentRow < 0 || iCurrentRow >= iRows)row_error = true;if (j<0 || j>= iColumns)column_error = true;if (row_error == true || column_error == true)(3);}catch(char){if (row_error == true)cerr << "行下标越界[" << iCurrentRow << "]";if (column_error = true)cerr << "列下标越界[" << j << "]";cout << "\n";}return tpBody[iCurrentRow * iColumns + j];}~Arraygody(){delete[]tpBody;}};template <class T> class Array {ArrayBody<T> tBody;Public;ArrayBody<T> operator[] (int i) {(4);return tBody;}Array(int iRsz, int iCsz) :(5) { }};void main(){Array<int> a1(10,20);Array<double> a2(3,5);int b1;double b2;b1 = a1[-5][10]; //有越界提示:行下标越界[-5]b1 = a1[10][15]; //有越界提示:行下标越界[10]b1 = a1[1][4]; //没有越界提示b2 = a2[2][6]; //有越界提示:列下标越界[6]b2 = a2[10][20]; //有越界提示:行下标越界[10]列下标越界[20]b2 = a2[1][4]; //没有越界提示}
考题
阅读下列C++程序和程序说明,将应填入(n)处的字句写在对应栏内。【说明】C++语言本身不提供对数组下标越界的判断。为了解决这一问题,在程序6中定义了相应的类模板,使得对厂任意类型的二维数组,可以在访问数组元素的同时,对行下标和列下标进行越界判断,并给出相应的提示信息。include<iostream.h>template <class T> class Array;template <class T> class ArrayBody {friend (1)T* tpBody;int iRows, iColumns, iCurrentRow;ArrayBody (int iRsz, int iCsz) {tpBody =(2)iRows = iRsz; iColumns =iCsz; iCurrentRow =-1;}public:T operator[] (int j) {bool row_error, column_error;row_error=column_error=false;try{if (iCurrentRow < 0 || iCurrentRow >=iRows)row_error=true;if (j < 0 || j >=iColumns)column_error=true;if ( row_error==true || column_error == true)(3)}catch (char) {if (row_error==true)cerr << "行下标越界[" << iCurrentRow << "] ";if (column_error== true )cerr << "列下标越界[" <<j << "]";cout << "\n";}return tpBody[iCurrentRow * iColumns +j];};~ArrayBody ( ) { delete[] tpBody; }};template <class T> class Array {ArrayBody<T> tBody;public:ArrayBody<T> operator[] (int i) {(4)return tBody;}Array (int iRsz, int iCsz) :(5) {}};void main(){ Array<int>a1(10,20);Array<double>a2(3,5);int b1;double b2;b1=a1[-5][10]; //有越界提示:行下标越界[-5]b1=a1[10][15]; //有越界提示:行下标越界[10]b1=a1[1][4]; //没有越界提示b2=a2[2][6]; //有越界提示:列下标越界[6]b2=s2[10][20]; //有越界提示:行下标越界[10]列下标越界[20]b2=a2[1][4]; //没有越界提示}
考题
阅读下列说明和C++程序,将应填入(n)处的字句写在对应栏内。【程序1说明】程序1中定义了数组的类模板,该模板使得对于任意类型的二维数组,可以在访问数组元素的同时,对行下标和列下标进行越界判断,并给出相应的提示信息(C++语言本身不提供对下标越界的判断)。【程序1】include < iostream. h >template < class T > class Array2D;template < class T > class Array2DBody {friend (1);T * tempBody;int iRows, iColumns, iCurrentRow;Array2DBody(int Rows,int Cols) {tempBody =(2);iRows = Rows;iColumns = Cols;iCurrentRow = -1;}public:T operator[ ] (int j){bool row_ error, column_ error;row_ error = column_ error = false;try {if ( iCurrentRow < 0||iCurrentRow > = iRows)row_ error = true;if( j < 0||j > = iColumns)column_error = true;if( row_error = = true [ [ column_ error = = true)(3);}catch(char) {if (row_error = = true)cerr < < "行下标越界"[" < < iCurrentRow < < "]";if( colmnn_error = = true)cerr< <"列下标越界[" < <j< <"]";cout < < "\n";}return tempBody[ iCurrentRow * iColumns + j ];}~ Array2 DBody ( ) { delete [ ] tempBody; } }; template < class T > class Array2D {Array2DBody < T > tBody;public:Array2DBody < T > operalor[ ] (int i) {tBody, iCurreutRow = i;(4);Array2D(int Rows,int Cols): (5) {} };void main( ){Array2D <int> al ( 10,20 );Array2D <double> a2(3,5);int bl;double b2;b1=a1[-5][10];//有越界提示:行下标越界[-5]b1=a1[10][15];//有越界提示:行下标越界[10]b1=a1[1][4];//没有越界提示b2=a2[2][6];//有越界提示:列下标越界[6]b2=a2[10][20];//有越界提示:行下标越界[10]列下标越界[20]b2=a2[1][4];//没有越界提示}
考题
下面的异常()为数组下标越界异常。A、Arithmetic ExceptionB、Null Pointer ExceptionC、Array Index Out Of Bounds ExceptionD、File Not Found Exception
考题
研究下面的Java代码: public class testException{ public static void main(String args[]){ int a[]={0,1,2,3,4}; int sum=0; try{ for(int i=1;i6;i++) sum=sum+a[i]; System.out.println("sum="+sum); } catch(ArrayIndexOutOfBoundsException ){ System.out.println("数组越界"); } finally{ System.out.println("程序结束");} } } 输出结果将是()。 A、10 数组越界 程序结束B、10 程序结束C、数组越界 程序结束D、程序结束
考题
在Java语言中,在程序运行时会自动检查数组的下标是否越界,如果越界,会抛掷下面的()异常。 A、NullpointerExceptionB、ArithmeticExceptioinC、ArrayIndexOutOfBoundsExceptionD、SecurityManager
考题
以下程序执行的结果是什么?() int[] myArray = new int[3]; try{ for(int i=0; i=myArray.length;i++){ myArray[i]=i*3; System.out.println("myArray数组的第"+i+"个元素的值是:"+myArray[i]); } }catch(ArrayIndexOurOfBoubsException e){ System.out.println("数组下标越界");} A、程序执行,屏幕上显示“数组下标越界”B、程序出现异常,屏幕上提示出现数组下标越界异常C、程序正常执行结束,屏幕上显示数组中每个元素的值D、程序编译出错
考题
下列说法正确的是()A、 在C#中,编译时对数组下标越界将作检查B、 在C#中,程序运行时,数组下标越界也不会产生异常C、 在C#中,程序运行时,数组下标越界是否产生异常由用户确定D、 在C#中,程序运行时,数组下标越界一定会产生异常
考题
单选题下列说法正确的是()A
在C#中,编译时对数组下标越界将作检查B
在C#中,程序运行时,数组下标越界也不会产生异常C
在C#中,程序运行时,数组下标越界是否产生异常由用户确定D
在C#中,程序运行时,数组下标越界一定会产生异常
考题
单选题以下程序执行的结果是什么?() int[] myArray = new int[3]; try{ for(int i=0; i=myArray.length;i++){ myArray[i]=i*3; System.out.println("myArray数组的第"+i+"个元素的值是:"+myArray[i]); } }catch(ArrayIndexOurOfBoubsException e){ System.out.println("数组下标越界");}A
程序执行,屏幕上显示“数组下标越界”B
程序出现异常,屏幕上提示出现数组下标越界异常C
程序正常执行结束,屏幕上显示数组中每个元素的值D
程序编译出错
考题
单选题研究下面的Java代码: public class testException{ public static void main(String args[]){ int a[]={0,1,2,3,4}; int sum=0; try{ for(int i=1;i6;i++) sum=sum+a[i]; System.out.println("sum="+sum); } catch(ArrayIndexOutOfBoundsException ){ System.out.println("数组越界"); } finally{ System.out.println("程序结束");} } } 输出结果将是()。A
10 数组越界 程序结束B
10 程序结束C
数组越界 程序结束D
程序结束
考题
单选题下面的异常()为数组下标越界异常。A
Arithmetic ExceptionB
Null Pointer ExceptionC
Array Index Out Of Bounds ExceptionD
File Not Found Exception
考题
单选题在Java语言中,在程序运行时会自动检查数组的下标是否越界,如果越界,会抛掷下面的()异常。A
NullpointerExceptionB
ArithmeticExceptioinC
ArrayIndexOutOfBoundsExceptionD
SecurityManager
热门标签
最新试卷