publicclassTest{publicintcall(){staticinti=0;i++;System.out.println(i);}publicstaticvoidmain(Stringargs[]){Testtest=newTest();test.call();}}
举一反三
- 下列程序的运行结果是: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: 给定以下代码,以下哪句是正确的?publicclassTest{privateinti=f();privateintj=10;privateintf(){returnj;}publicstaticvoidmain(Stringargs[]){System.out.println((newTest()).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(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);}}