写出下面程序的输出( )。 public class Test { public static void main (String args[ ]) { iht x=1, y=2; System. out. println ("result="+x+y); System. out. println ("result="+(x+y)); A.result=12 result=12 B.result=3 result=3 C.result=3 result=12 D.result=12 result=3
举一反三
- 下面程序段的输出结果是( )。 public class Test public static void main ( String[] args) int result=0; for ( int i=1;i<=5;i++) if ( i%2==0 ) continue; result + =i; System. out. println ("result is " + result ); A: result is 7 B: result is 8 C: result is 9 D: result is 10
- 下面程序段的输出结果是( )。 public class Test public static void main (String[] args) int n=10,result=0; for (int i=1;i<=n;i++) result+=i; System.out.println("result is"+result); A: A) result is 55 B: B) result is 45 C: C) result is 56 D: D) result is 54
- 下面的方法,当输入为2的时候返回值是多少?( ) public static int getValue(int i) { int result = 0; switch (i) { case 1: result = result + i; case 2: result = result + i * 2; case 3: result = result + i * 3; } return result; }
- 下列程序的输出结果是______。 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: 以上都不对
- 以下代码执行的结果是:( )int i=2;int result = 0;switch (i) {case 1:result = result + i;case 2:result = result + i * 2;case 3:result = result + i * 3;}System.out.println(result); A: 0 B: 2 C: 4 D: 10