现有:voidtopGo(){try{middleGo();}catch(Exceptione){System.out.print("catch");}}voidmiddleGo()throwsException{go();system.out.print("latemiddle");}voidgo()throwsExceptiOn{thrownewException();}如果调用topGo(),则结果为:()
A.latemiddle
B.catch
C.latemiddlecatch
D.catchIatemiddle
第1题:
classOrderimplementsRunnable{publicvoidrun(){try{Thread.sleep(2000);}catch(Exceptione)System.out.print("in");publicstaticvoidmain(String[]args){Threadt=newThread(newOrder());t.start();System.out.print("pre");try{t.join();}catch(Exceptione){}System.out.print("post");可产生哪两项结果?()
A.preinpost
B.prein
C.inpostpre
D.inprepost
E.prepostin
第2题:
现有
classParserextendsUtils{
publicstaticvoidmain(String[]args){
try{System.out.print(newParser().getlnt("42"))
}catch(Exceptione){
System.out.println("Exc");}
}
intgetlnt(Stringarg)throwsException{
returnInteger.parselnt(arg);
}
}
classUtils{
intgetlnt(){return42;}
}
结果是什么?()
第3题:
现有:classBirds{publicstaticvoidmain(String[]args){try{thrownewException();}catch(Exceptione){try{thrownewException();}catch(Exceptione2){System.out.print("inner");}System.out.print("middle");}System.out.print("outer");}}结果是()
A.innerouter
B.middleouter
C.innermiddleouter
D..编译失败
第4题:
现有:
classWaitingimplementsRunnable{
booleanflag=false;
publicsynchronizedvoidrun(){
if(flag){
flag=false;
System.out.print("1");
try{this.wait();)catch(Exceptione){}
System.out.print("2");
}
else{
flag=true;
System.out.print("3");
try{Thread.sleep(2000);}catch(Exceptione){}
System.out.print("4");
notify();
}
}
publicstaticvoidmain(String[]args){
Waitingw=newWaiting();
newThread(w).start();
newThread(w).start();
}
}
以下哪两项是正确的?()
第5题:
现有:classParserextendsUtils{publicstaticvoidmain(String[]args){try{System.out.print(newParser().getlnt("42"));}catch(Exceptione){System.out.println("Exc");}}intgetlnt(Stringarg)throwsException{returnInteger.parselnt(arg);}classUtils{intgetlnt(Stringarg){return42;}}结果为()
A.42
B.Exc
C.42Exc
D.编译失败