现有: 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"); } } } 结果是什么?() A、numberB、runtimeC、forty numberD、编译失败
现有: 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"); } } } 结果是什么?()
- A、number
- B、runtime
- C、forty number
- D、编译失败
相关考题:
classNumber{publicstaticvoidmain(String[]args){try{System.out.print(Integer.parseInt(forty));}catch(RuntimeExceptionr){System.out.print(runtime);}catch(NumberFormatExceptione){System.out.print(number);}}}结果是什么?()A.fortyB.numberC.runtimeD.编译失败
现有:classNumber{publicstaticvoidmain(String[]aras){try{System.out.print(Integer.parselnt(forty));}catch(RuntimeExceptionr){System.out.print(runtime);}catch(NumberFormatExceptione){system..ut.print(number);}}}结果是什么?()A.numberB.runtimeC.fortynumberD.编译失败
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.
现有: class Parser extends Utils { public static void main (String[] args) { try{System.out.print (new Parser().getlnt("42")); } catch (Exception e) { System.out.println("Exc"); } } int getlnt (String arg) throws Exception { return Integer.parselnt (arg); } class Utils { int getlnt (String arg) {return 42; } } 结果为() A、 42B、 ExcC、 42ExcD、编译失败
现有 class Parser extends Utils { public static void main (String [] args) { try { System.out.print (new Parser () .getlnt ("42")) } catch (Exception e) { System.out.println ("Exc") ; } } int getlnt (String arg) throws Exception { return Integer.parselnt (arg) ; } } class Utils { int getlnt () { return 42; } } 结果是什么?() A、 42ExcB、 ExcC、 42D、编译失败
class Number { public static void main(String [] args) { try { System.out.print(Integer.parseInt("forty ")); } catch (RuntimeException r) { System.out.print("runtime "); } catch (NumberFormatException e) { System.out.print("number "); } } } 结果是什么?() A、fortyB、numberC、runtimeD、编译失败
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.
class Parser extends Utils { public static void main (String [] args) { try { System.out.print(new Parser().getInt("42")); } catch (NumberFormatException n) { System.out.println("NFExc "); } } int getInt(String arg) throws NumberFormatException { return Integer.parseInt(arg); } } class Utils { int getInt(String arg) { return 42; } } 结果为:() A、42B、NFExcC、42NFExcD、编译失败
现有: 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 }} 可能会产生哪两项结果 ?() A、 before catchB、 before after doneC、 before catch doneD、 before after catch
现有: class Parser extends Utilis { public static void main (String [] args) { try { System. out.print (new Parser ( ) .getlnt ("42")} ; } catch (NumberFormatException n) { System.out .println ( "NFExc" ) ; } } int getlnt (String arg) throws NumberFormatException{ return Integer.parselnt (arg) ; } class Utils { int getlnt (String arg) { return 42; } } 结果为 :()A、 NFExcB、 42C、 42NFExcD、编译失败
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.
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.
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 } } 可能会产生下面哪两项结果?() A、beforeB、before catchC、before after doneD、before catch done
public class TestApp{ public static void main(String[] args){ try{ int i = 0; int j = 1 / i; String myname=null; if(myname.length()2) System.out.print(“1”); }catch(NullPointerException e){ System.out.print(“2”); } catch(Exception e){ System.out.print(“3”); } } } 上述程序运行后的输出是哪项?()A、 3B、 2C、 231D、 32
现有: 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、.编译失败
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、innerB、inner outerC、middle outerD、inner middle outer
class Order implements Runnable { public void run () { try { Thread.sleep (2000) ; } catch (Exception e) System.out.print("in") ; public static void main (String [] args) { Thread t = new Thread (new Order ()) ; t.start () ; System.out.print ("pre ") ; try { t.join () ; } catch (Exception e) { } System.out.print ("post") ; 可产生哪两项结果?() A、 pre in postB、 pre inC、 in post preD、 in pre postE、 pre post in
单选题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.
单选题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
单选题现有: class Parser extends Utils { public static void main (String[] args) { try{System.out.print (new Parser().getlnt("42")); } catch (Exception e) { System.out.println("Exc"); } } int getlnt (String arg) throws Exception { return Integer.parselnt (arg); } class Utils { int getlnt (String arg) {return 42; } } 结果为()A 42B ExcC 42ExcD编译失败
单选题现有: 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.
单选题现有: 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.
多选题class Order implements Runnable { public void run() { try { Thread.sleep(2000); } catch (Exception e) { } System.out.print("in "); } public static void main(String [] args) { Thread t = new Thread(new Order()); t.start(); System.out.print("pre "); try { t.join(); } catch (Exception e) { } System.out.print("post "); } } 可产生哪两项结果?()Ain preBpre inCin pre postDpre in post
单选题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.