下面程序运行将会输出结果( )。try{String[] lines = new String[2];for(int i=0; iSystem.out.println(“The End”);}catch(NullPointerException e){System.out.printn(“***********”);}catch(ArrayIndexOutOfBoundsException e){System.out.println(“++++++”)}catch(Exception e){System.out.println(“==========”)}
A: 00The End
B: 00++++++
C: ***********
D: ***********++++++==========
A: 00The End
B: 00++++++
C: ***********
D: ***********++++++==========
举一反三
- 下面程序运行将会输出结果( )。try{String[] lines = new String[2];for(int i=0; i<3; i++) System.out.println(lines[i].length());System.out.println(“The End”);}catch(NullPointerException e){System.out.printn(“***********”);}catch(ArrayIndexOutOfBoundsException e){System.out.println(“++++++”)}catch(Exception e){System.out.println(“==========”)}[/i] A: 00++++++ B: ***********++++++========== C: *********** D: 00The End
- 下列程序的输出结果是______。 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: 以上都不对
- 请看下面的程序代码,当 n 为( )值时,程序段将输出字符串 second。 [br][/br] switch(n) { [br][/br] case 0: System .out .println(“first”); [br][/br] case 1: [br][/br] case 2: System .out .println(“second”); break; [br][/br] default: System .out .println(“end”); [br][/br] }(2.0) A: 0 B: 1 C: 2 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: 以上都不对
- 中国大学MOOC: 下列代码中构造方法的返回类型是()public class Village { Village () { System .out .println(“hiding in Village”) ; } public static void main( String args [ ]) { Village c =new Village ( ) ;}class Village { public static void main( String args [ ]) { Village c =new Village ( ) ; } Village () { System .out .println(“hiding in Village”) ; } }