A.0
B.null
C.Compilationfails.
D.ANullPointerExceptionisthrownatruntime.
E.AnArrayIndexOutOfBoundsExceptionisthrownatruntime.
第1题:
A.NULL
B.Compilationfails.
C.Thecoderunswithnooutput.
D.Anexceptionisthrownatruntime.
NULLshouldbe"null".
第2题:
A.finished
B.Compilationfails.
C.AnAssertionErroristhrown.
D.AnAssertionErroristhrownandfinishedisoutput.
Thisquestionisabittrickybecauseitlacksthefollowinginformation:Itshouldincludeastatementthatsayswhetherornotassertionsareenabled.Iftheyareindeedenabled,the
correctionanswerisC.butiftheyarenot,thecorrectanswerisA.Assertionsarenotenabledbydefaultsoifthequestionisnotchanged,themostlogicalanswerisA.
第3题:
interface A{
int x = 0;
}
class B{
int x =1;
}
class C extends B implements A {
public void pX(){
System.out.println(x);
}
public static void main(String[] args) {
new C().pX();
}
}
错误。在编译时会发生错误(错误描述不同的JVM 有不同的信息,意思就是未明确的
x 调用,两个x 都匹配(就象在同时import java.util 和java.sql 两个包时直接声明Date 一样)。
对于父类的变量,可以用super.x 来明确,而接口的属性默认隐含为 public static final.所以可
以通过A.x 来明确。
第4题:
A.finished
B.Compilationfails.
C.AnAssertionErroristhrownandfinishedisoutput.
D.AnAssertionErroristhrownwiththemessage“assertionfailed”.
E.AnAssertionErroristhrownwiththemessage“assertionpassed”.
第5题:
A.x=0
B.x=42
C.Compilationfailsbecauseofanerrorinline2ofclassTest2.
D.Compilationfailsbecauseofanerrorinline3ofclassTest1.
E.Compilationfailsbecauseofanerrorinline4ofclassTest2.