中国大学MOOC:编译并运行下面的程序,运行结果为( )。publicclassMain{publicstaticvoidmain(String[]args){AAobj=newBB();System.out.println(obj.f(4,6));}}classAA{doublef(doublex,doubley){returnx*y;}}classBBextendsAA{doublef(doublex,doubley){returnx+y;}}
举一反三
- 下列程序段运行结果是()interfaceA{doublef(doublex,doubley);}classBimplementsA{publicdoublef(doublex,doubley){returnx*y;}intg(inta,intb){returna+b;}}publicclassE{publicstaticvoidmain(String[]args){Aa=newB();System.out.println(a.f(3,5));Bb=(B)a;System.out.println(b.g(3,5));}} A: 15.0,8.0 B: 15.08 C: 158 D: 815
- interfaceA{doublef(doublex,doubley);}classBimplementsA{publicdoublef(doublex,doubley){returnx*y;}intg(inta,intb){returna+b;}}publicclassE{publicstaticvoidmain(Stringargs[]){Aa=newB();System.out.println(a.f(3,5));//【代码1】Bb=(B)a;System.out.println(b.g(3,5));//【代码2】}}代码1输出()代码2输出()
- 执行下列程序,输出结果为()。publicclassB{publicstaticvoidmain(String[]args){intx=5;doubley=10.5f;floatz=(float)(x*y);System.out.println(z);}}
- 下列程序编译并运行的结果为()publicclassTest{publicstaticvoidmain(String[]args){try{inti=1;System.out.println(i++);}finally{System.out.println(++i);}}}
- 中国大学MOOC:运行下面的程序,正确的输出结果是()。#includeintmain(){doublex=68.7563,y=-789.127;printf(%f,%10.2f\n,x,y);return0;}