下列程序的执行结果是______。 public class Test { public static void main(String[] args) { int[] x={0, i,2,3}; for(int i=0;i<3;i+=2) { try{ System.out.println(x[i+2]/x[i]+x[i+1]); }catch(ArithmeticException e) { System.out.println("error1"); }catch(Exception e) { System.out.println ("error2"); } } } }[/i]
A: error1
B: error2
C: error1 error2
D: 2 error2
A: error1
B: error2
C: error1 error2
D: 2 error2
举一反三
- 下列程序的输出结果是______。 public class Test public static void main(String[]args) int[]array=(2,4,6,8,10); int size=6; int result=-1; try for(int i=0;i<size&&result==-1;) if(array[i]==20)result=i; catch(ArithmeticException e)﹛ System.out.println("Catch———1"); catch(ArrayIndexOutOfBoundsException e) System.OUt.println("Catch———2"); catch(Exception e) System.out.println("Catch———3");[/i] A: Catch———1 B: Catch———2 C: Catch———3 D: 以上都不对
- 下列程序的输出结果是______。 Public class Test Public static void main(String[] args) int[]array=(2,4,6,8,10); int size=6; int result=-1; try for(int i=0; i<size & & resuIt==-1;) if(array[i]==20)result=i; catch(ArithmeticException e) System. out. println("Catch---1"); catch(ArrayIndexOutofBoLmdsException e) System. out. println("Catch---2"); catch(Exception e) System. out. println("Catch---3");[/i] A: Catch---1 B: Catch---2 C: Catch---3 D: 以上都不对
- 以下程序的运行结果为( )。public class Test { public static void main(String args[ ]) { int i=0, j=2; do { i=++i; j--; } while(j>0); System.out.println(i); }} A: 0 B: 1 C: 2 D: 3
- 下列程序的运行结果是()。 public class Test public static void main ( String [ ] args ) int count = 0 for( int i = 1 i < 5 i = 2) for( int j = 1 j< = 10 j = 3) count System .out .print (count ) _
- 以下程序的输出结果是【 】。 class Program { public static void Main(string[] args) { int[] a = new int[3] { 1, 2, 3 }; for (int i = 0; i < 3; i++) Console.Write("{0} ", a[i]); Console.WriteLine(); int[] b = a; for (int i = 0; i < 3; i++) b[i] = 2 * b[i]; for (int i = 0; i < 3; i++) Console.Write("{0} ", a[i]); Console.WriteLine(); Console.Read(); } }[/i][/i][/i][/i]