中国大学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;}}
10.0
举一反三
- 下列程序段运行结果是()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;}
内容
- 0
若程序中定义了以下函数fun,则以下选项中对该函数错误的声明是doublefun(doublex,doubley){returnx+y;}
- 1
以下程序执行后的输出为:#includedoublef1(doublex){return1.0/x;}doublef2(doublex){returnx*x;}intmain(){inti=3;double(*f[2])(double)={f1,f2};cout< A: 0.333333 B: 0.5 C: 9 D: 4
- 2
阅读下面的程序 importjava.util.*; classHashSetDemo{ publicstaticvoidmain(String[]args){ HashSeths=newHashSet(); hs.add("abc"); hs.add("abc"); System.out.println(hs); } } 下列选项中,哪一个是程序的运行结果
- 3
若有函数定义:int fun(){doublex=23.5;returnx;},则函数的返回结果是()
- 4
请阅读下列的程序publicclassExample01{publicstaticvoidmain(String[]args){intnum=127;byteb=num;System.out.println(b);}}程序的运行结果是()