下列程序编译并运行的结果为()publicclassTest{publicstaticvoidmain(String[]args){try{inti=1;System.out.println(i++);}finally{System.out.println(++i);}}}
举一反三
- 请阅读下面的程序,sum的值为()publicclassTest{publicstaticvoidmain(String[]args){intsum=0;for(inti=1;i=100;i++){if(i%2==1){continue;}sum+=i;}System.out.println(sum=+sum);}}
- 当编译并运行下面程序时会发生什么结果: publicclassHope{ publicstaticvoidmain(Stringargv[]){ Hopeh=newHope(); } protectedHope(){ for(inti=0;i<10;i++){ System.out.println(i); } } }
- 设有如下程序publicclasstest{publicstaticvoidmain(Stringargs[]){IntegerintObj=Integer.valueOf(args[args.length-1]);inti=intObj.intValue();if(args.length>1) System.out.println(i);if(args.length>0) System.out.println(i-1);elseSystem.out.println(i-2);}}运行程序,输入如下命令
- 下列程序的运行结果是:publicclassTest{publicstaticvoidmain(Stringargs[]){intm[]={1,2,3,4,5,6,7,8};intsum=0;for(inti=0;i8;i++){sum=sum+m[i];if(i==3)break;}System.out.println(sum);}}
- 中国大学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”) ; } }