单选题现有: void topGo() { try { middleGo(); } catch (Exception e) { System.out.print("catch"); } } void middleGo() throws Exception { go(); system.out.print("late middle"); } void go() throws ExceptiOn { throw new Exception(); } 如果调用 topGo () ,则结果为:()A late middleB catchC late middle catchD catch Iate middle
单选题
现有: void topGo() { try { middleGo(); } catch (Exception e) { System.out.print("catch"); } } void middleGo() throws Exception { go(); system.out.print("late middle"); } void go() throws ExceptiOn { throw new Exception(); } 如果调用 topGo () ,则结果为:()
A
late middle
B
catch
C
late middle catch
D
catch Iate middle
参考解析
解析:
暂无解析
相关考题:
Assumethecustomtagmy:errorPronealwaysthrowsajava.lang.RuntimeExceptionwiththemessageFilenotfound.AnerrorpagehasbeenconfiguredforthisJSPpage.Whichoptionpreventstheexceptionthrownbymy:errorPronefrominvokingtheerrorpagemechanism,andoutputsthemessageFilenotfoundintheresponse?()A.c:trycatch=exmy:errorProne//c:try${ex.message}B.c:catchvar=exmy: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
现有:voidtopGo(){try{middleGo();}catch(Exceptione){System.out.print(catch);}}voidmiddleGo()throwsException{go();system.out.print(latemiddle);}voidgo()throwsExceptiOn{thrownewException();}如果调用topGo(),则结果为:()A.latemiddleB.catchC.latemiddlecatchD.catchIatemiddle
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?() A、 test endB、 Compilation fails.C、 test runtime endD、 test exception endE、 A Throwable is thrown by main at runtime.
考虑下列Java代码: Classc A{ Public static void main(String []args){ Try{ System.out.println(“hello,world”) } } } 其中错误的是()。 A、没有catch或finally块B、没有抛出异常的代码不能出现在try代码块内C、如果没有catch块而使用try,main()会总是抛出异常.D、class A 没有throws IOException
现有: 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?() A、只在第11行B、在第8行和第11行C、在第5行、第8行和第11行D、在第2行、第5行、第8行和第11行
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?() A、 nullB、 finallyC、 null finallyD、 Compilation fails.E、 finally exception
下面关于try、catch和finally语句块的组合使用,正确的是()A、try{,}B、try{,}finally{,}C、try{,}catch{,}finally{,}D、try{,}catch{,}catch{,}
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?() A、 ACB、 BDC、 ACDD、 ABCDE、 Compilation fails.
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?() A、 testB、 ExceptionC、 Compilation fails.D、 NullPointerException
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?() A、 BDB、 BCDC、 BDED、 BCDEE、 ABCDEF、 Compilation fails.
现有: void topGo() { try { middleGo(); } catch (Exception e) { System.out.print("catch"); } } void middleGo() throws Exception { go(); system.out.print("late middle"); } void go() throws ExceptiOn { throw new Exception(); } 如果调用 topGo () ,则结果为:() A、 late middleB、 catchC、 late middle catchD、 catch Iate middle
现有: class Birds { public static void main (String [] args) { try { throw new Exception () ; } catch (Exception e) { try { throw new Exception () ; } catch (Exception e2) { System.out.print ("inner "); } System. out.print ( "middle" ) ; } System.out.print ("outer") ; } } 结果是()A、 inner outerB、 middle outerC、 inner middle outerD、.编译失败
现有 1. class Calc { 2. public static void main(String [] args) { 3. try { 4. int x = Integer.parselnt ("42a") ; 5. //insert code here 6. System.out.print ("oops"); 7. } 8. } 9. } 下面哪两行分别插入到第五行,会导致输 "oops" ? () A、 } catch (IllegalArgumentException e) {B、 } catch (IllegalStateException c) {C、 } catch (NumbelFormatException n) {D、 } catch (ClassCastException c) {
Assume the custom tag my:errorProne always throws a java.lang.RuntimeException with the message "Filenot found." An error page has been configured for this JSP page. Which option prevents the exceptionthrown by my:errorProne from invoking the error page mechanism, and outputs the message "File notfound" in the response?()A、c:try catch="ex"my:errorProne //c:try${ex.message}B、c:catch var="ex"my:errorProne //c:catch${ex.message}C、c:try. my:errorProne /. /c:try. c:catch var="ex" /. ${ex.message}D、c:try. my:errorProne /. c:catch var="ex" /. ${ex.message}. /c:try
单选题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?()A BDB BCDC BDED BCDEE ABCDEF Compilation fails.
单选题现有: class Birds { public static void main (String [] args) { try { throw new Exception () ; } catch (Exception e) { try { throw new Exception () ; } catch (Exception e2) { System.out.print ("inner "); } System. out.print ( "middle" ) ; } System.out.print ("outer") ; } } 结果是()A inner outerB middle outerC inner middle outerD.编译失败
单选题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?()A test endB Compilation fails.C test runtime endD test exception endE A Throwable is thrown by main at runtime.
单选题Assume the custom tag my:errorProne always throws a java.lang.RuntimeException with the message "Filenot found." An error page has been configured for this JSP page. Which option prevents the exceptionthrown by my:errorProne from invoking the error page mechanism, and outputs the message "File notfound" in the response?()Ac:try catch=exmy:errorProne //c:try${ex.message}Bc:catch var=exmy:errorProne //c:catch${ex.message}Cc:try. my:errorProne /. /c:try. c:catch var=ex /. ${ex.message}Dc:try. my:errorProne /. c:catch var=ex /. ${ex.message}. /c:try
单选题What is wrong with the following code?() class MyException extends Exception {} public class Qb4ab { public void foo() { try { bar(); } finally { baz(); } catch (MyException e) {} } public void bar() throws MyException { throw new MyException(); } public void baz() throws RuntimeException { throw new RuntimeException(); } }ASince the method foo() does not catch the exception generated by the method baz(), it must declare the RuntimeException in its throws clause.BA try block cannot be followed by both a catch and a finally block.CAn empty catch block is not allowed.DA catch block cannot follow a finally block.EA finally block must always follow one or more catch blocks.
单选题现有: class Number{ public static void main(String [] aras) { try { System.out.print (Integer.parselnt ("forty")); } catch (RuntimeException r) { System.out.print ("runtime"); } catch (NumberFormatException e) { system..ut.print("number"); } } } 结果是什么?()AnumberBruntimeCforty numberD编译失败
单选题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() { throw new RuntimeException(); } } What is the result? ()A ABB BCC ABCD BCDE Compilation fails.
单选题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?()A testB ExceptionC Compilation fails.D NullPointerException
单选题static void test() throws Error { if (true) throw new AssertionError(); System.out.print(”test “); } public static void main(String[] args) { try { test(); } catch (Exception ex) { System.out.print(”exception “); } System.out.print(”elld “); } What is the result?()A endB Compilation fails.C exception endD exception test endE A Throwable is thrown by main.F An Exception is thrown by main.
单选题现有: 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?()A只在第11行B在第8行和第11行C在第5行、第8行和第11行D在第2行、第5行、第8行和第11行
多选题现有: class Flow { public static void main(String [] args) try { System. out .print ("before") ; doRiskyThing ( ) ; System.out.print ("after ") ; } catch (Exception fe) { System.out.print ("catch") ; } System. out .println ( " done") ; } public static void doRiskyThing() throws Exception{ // this code returns unless it throws an Exception }} 可能会产生哪两项结果 ?()Abefore catchBbefore after doneCbefore catch doneDbefore after catch
单选题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?()A nullB finallyC null finallyD Compilation fails.E finally exception
单选题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?()A ACB BDC ACDD ABCDE Compilation fails.
单选题现有: void topGo() { try { middleGo(); } catch (Exception e) { System.out.print("catch"); } } void middleGo() throws Exception { go(); system.out.print("late middle"); } void go() throws ExceptiOn { throw new Exception(); } 如果调用 topGo () ,则结果为:()A late middleB catchC late middle catchD catch Iate middle