A: ArrayIndexOutOfBoundsException
B: IOException e
C: NumberFormatException e
D: ArithmeticException e
举一反三
- 运行下面程序时,会产生什么异常?( )public class sdw{ public static void main(String[] args) {int x = 0;int y = 5/x;int[] z = {1,2,3,4};int p = z[3];}} A: ArithmeticException B: NumberFormatException C: ArrayIndexOutOfBoundsException D: IOException
- 以下选项错误的是 A.main() { int x,y,z; x=0;y=x-1; z=x+y;} B.main() { int x,y,z; x=0,y=x+1; z=x+y;} C.main() { int x;int int y; x=0,y=x+1; z=x+y;} D.main() { int x,y,z; x=0;y=x+1; z=x+y,}
- 以下程序执行后的输出结果是 #include <iostream> using namespace std; void try(int,int,int,int); int main () int x,y,z,r; x =1 ; y = 2; try(x,y,z,r); cout<<r<<endl; return 0; void try(int x,int y,int z,int r) z = x+y; x = x*x; y = y*y; r = z+x+y; A: 18 B: 9 C: 10 D: 不确定
- 运行下面的程序时,会产生( )。 public class Test{ public static void main(String args[ ] ) { int x =0; int y = 2/x; int z[ ] = {1,2,4,6}; int p=z[4]; } } A: ArrayIndexOutOfBoundsExcePtion异常 B: NumberFormatException异常 C: ArithmeticException异常 D: ArithmeticException异常和ArrayIndexOutOfBoundsExcePtion异常
- class Demo{ public static void main(String[] args){ int x = 0; try{ x = div(1,2); }catch(Exception e){ System.out.println(e); } System.out.println(x) ; } public static int div(int a,int b){ return a / b ; } }
内容
- 0
,d); return 0; } int dif(int x,int y,int z) { int max(int x,int y,int z); int min(int x
- 1
类A有3个int型成员变量a、b、c,则( )是类A的正确构造方法。 A: void A(){a=0; b=0; c=0; } B: public void A(){ a=0; b=0; c=0;} C: public int A (int x, int y, int z){ a=x; b=y; c=z; } D: public A(int x,int y, int z) { a=x; b=y; c=z; }
- 2
下列代码的输出结果是___________________ for(int y=0; y<4; y++){ for(int x=0; x<5; x++){ System.out.print("*"); } System.out.println(); }
- 3
以下程序没有语法问题的是() A: B: include<;stdio.h>;int main( ){int x , y = 5 ; printf( "%d\n" , x / y ) ; return 0 ;} C: D: include<;stdio.h>;int main( ){int x = 3 ;y = 5 ; printf( "%d\n" , x / y ) ; return 0 ;} E: F: include<;stdio.h>;int main( ){int x = 3 ,y ; printf( "%d\n" , x / y ) ;y = 5; return 0 ;} G: H: include<;stdio.h>;int main( ){int x = 3 , y = 5 ; printf( "%d\n" , x / y ) ; return 0 ;}
- 4
以下程序的运行结果是( )。 main() { int a=-5,b=1,c=1; int x=0,y=2,z=0; if(c>0) x= x + y; if(a<=0) { if(b>0) if(c<=0) y= x - y; } else if(c>0) y= x - y; else z= y; printf("%d,%d,%d\n", x, y, z); }