题目内容

运行如下程序时,显示什么结果?()classTest{public static void main(String[] args) {try {method();System.out.println("After the method call");}catch (NumberFormatException ex) {System.out.println("NumberFormatException");}catch (RuntimeException ex) {System.out.println("RuntimeException");}} static void method() {String s = "5.6";Integer.parseInt(s); // Cause a NumberFormatExceptionint i = 0;int y = 2 / i;System.out.println("Welcome to Java");}}

A. 程序显示 NumberFormatException.
B. 程序显示NumberFormatException followed by After the method call.
C. 程序显示NumberFormatException followed by RuntimeException.
D. The program has a compilation error.
E. 程序显示RuntimeException.

查看答案
更多问题

有以下方法的定义,请选择该方法的返回类型(D)ReturnType method(byte x, double y) {return (short)x/y*2;}

A. byte
B. short
C. int
D. double

以下代码的输出结果为:()public class Test { public static void main(String[] args) { Object o1 = new Object(); Object o2 = new Object(); System.out.print((o1 == o2) + " " + (o1.equals(o2))); }

A. false false
B. true true
C. false true
D. true false

int x, b=0; for(x = 0; x <= 5; ++x){ if (x == 2) break; ++b; }

A. 0
B. 1
C. 2
D. 3

给出以下程序:1. public class Electronic implements Device2.{ public void doIt() { } }3. abstract class Phone1 extends Electronic { }5. abstract class Phone2 extends Electronic6.{ public void doIt(int x) { } }7. class Phone3 extends Electronic implements Device8.{ public void doStuff() { } }9. interface Device { public void doIt(); }程序输出结果为?()

A. Compilation succeeds
B. Compilation fails with an error on line 1
Compilation fails with an error on line 3
D. Compilation fails with an error on line 5

答案查题题库