try{ int x = 0; int y= 5; int z = y/x; }catch(_______________){ System.out.println("除数不能为0"); } 横线处应填写什么?
A: ArrayIndexOutOfBoundsException
B: IOException e
C: NumberFormatException e
D: ArithmeticException e
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 ; } }