late middle
catch
late middle catch
catch Iate middle
第1题:
static void test() throws RuntimeException { try { System.out.print(”test “); throw new RuntimeException(); } catch (Exception ex) { System.out.print(”exception “); } } public static void main(String[] args) { try { test(); } catch (RuntimeException ex) { System.out.print(”runtime “); } System.out.print(”end “); } What is the result?()
第2题:
现有: 1. class Propeller2 { 2. pulolic static void main (String[]args)//add code here? 3. { new Propeller2().topGo(); } 4. 5.void topGo() //add code here? 6. { middleGo(); } 7. 8.void middleGo() //add code here? 9. { go(); System.out.println ("late middle"); } void go() //add code here? 12. {throw new Exception(); } 13. } 为使代码通过编译,需要在哪一行加入声明throws Exception?()
第3题:
Assumethecustomtagmy:errorPronealwaysthrowsajava.lang.RuntimeExceptionwiththemessage"Filenotfound."AnerrorpagehasbeenconfiguredforthisJSPpage.Whichoptionpreventstheexceptionthrownbymy:errorPronefrominvokingtheerrorpagemechanism,andoutputsthemessage"Filenotfound"intheresponse?()
A.<c:trycatch="ex"><my:errorProne/></c:try>${ex.message}
B.<c:catchvar="ex"><my:errorProne/></c:catch>${ex.message}
C.<c:try>.<my:errorProne/>.</c:try>.<c:catchvar="ex"/>.${ex.message}
D.<c:try>.<my:errorProne/>.<c:catchvar="ex"/>.${ex.message}.</c:try>
第4题:
public static void main(String[] args) { try { args=null; args[0] = “test”; System.out.println(args[0]); } catch (Exception ex) { System.out.println(”Exception”); } catch (NullPointerException npe) { System.out.println(”NullPointerException”); } } What is the result?()
第5题:
下面关于try、catch和finally语句块的组合使用,正确的是()
第6题:
考虑下列Java代码: Classc A{ Public static void main(String []args){ Try{ System.out.println(“hello,world”) } } } 其中错误的是()。
第7题:
static void test() { try { String x=null; System.out.print(x.toString() +“ “); } finally { System.out.print(“finally “); } } public static void main(String[] args) { try { test(); } catch (Exception ex) { System.out.print(”exception “); } } What is the result?()
第8题:
现有: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
第9题:
public class X { public static void main(String [] args) { try { badMethod(); System.out.print(“A”); } catch (Exception ex) { System.out.print(“B”); } finally { System.out.print(“C”); } System.out.print(“D”); } public static void badMethod() {} } What is the result?()
第10题:
public class X { public static void main(String [] args) { try { badMethod(); System.out.print(“A”); } catch (RuntimeException ex) { System.out.print(“B”); } catch (Exception ex1) { System.out.print(“C”); } finally { System.out.print(“D”); } System.out.print(“E”); } public static void badMethod() { throw new RuntimeException(); } } What is the result?()