当编译并运行下面程序时会发生什么结果:
publicclassHope{
publicstaticvoidmain(Stringargv[]){
Hopeh=newHope();
}
protectedHope(){
for(inti=0;i<10;i++){
System.out.println(i);
}
}
}
publicclassHope{
publicstaticvoidmain(Stringargv[]){
Hopeh=newHope();
}
protectedHope(){
for(inti=0;i<10;i++){
System.out.println(i);
}
}
}
举一反三
- 下列程序编译并运行的结果为()publicclassTest{publicstaticvoidmain(String[]args){try{inti=1;System.out.println(i++);}finally{System.out.println(++i);}}}
- 中国大学MOOC: 试图编译和运行以下代码的结果是:classBase{privateBase(){System.out.println(0);}publicBase(inti){System.out.println(i);}}publicclassTestextendsBase{publicTest(){super(1);};publicstaticvoidmain(Stringargv[]){Testt=newTest();}}
- 下列程序的运行结果是: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);}}
- 下面程序的运行结果是()。#includeintmain(){inti;for(i=0;i<10;i++);printf(“%d”,i);return0;}
- 运行下面程序段的输出结果是()。inti;for(i=0;i<10;i++);printf("%d",i);