单项选择题
class Base {
Base() { System.out.print(“Base”); }
}
public class Alpha extends Base {
public static void main( String[] args ) {
new Alpha();
new Base();
}
}
What is the result?()
A. Base
B. BaseBase
C. Compilation fails.
D. The code runs with no output.
E. An exception is thrown at runtime.
点击查看答案&解析
相关考题
-
单项选择题
10.publicObjectm(){11.Objecto=newFloat(3.14F);12.Object[]oa=newObject[1];13.oa[0]=o;14.o=null;15.returnoa[0];16.}WhenistheFloatobject,createdinline11,eligibleforgarbagecollection?()
A. Just after line 13.
B. Just after line 14.
C. Never in this method.
D. Just after line 15 (that is, as the method returns). -
填空题
1.publicclassTest{2.publicstaticStringoutput=””;3.4.publicstaticvoidfoo(inti){5.try{6.if(i==1){7.thrownewException();8.}9.output+=“1”;10.}11.catch(Exceptione){12.output+=“2”;13.return;14.}15.finally{16.output+=“3”;17.}18.output+=“4”;19.}20.21.publicstaticvoidmain(Stringargs[]){22.foo(0);23.foo(1);24.25.}26.}Whatisthevalueofthevariableoutputatline23?() -
单项选择题
class Super { public Integer getLenght() { return new Integer(4); } } public class Sub extends Super { public Long GetLenght() { return new Long(5); } public static void main(String[] args) { Super sooper = new Super(); Sub sub = new Sub(); System.out.println( sooper.getLenght().toString() + “,” + sub.getLenght().toString() ); } } What is the output?()
A. 4,4
B. 4,5
C. 5,4
D. 5,5
E. Compilation fails.