test
Exception
Compilation fails.
NullPointerException
第1题:
try { int x = 0; int y = 5 / x; } catch (Exception e) { System.out.println(“Exception”); } catch (ArithmeticException ae) { System.out.println(“Arithmetic Exception”); } System.out.println(“finished”); What is the result?()
第2题:
public class Test { private static int[] x; public static void main(String[] args) { System.out.println(x[0]); } } What is the result?()
第3题:
publicstaticvoidmain(String[]args){try{args=null;args[0]=test”;System.out.println(args[0]);}catch(Exceptionex){System.out.println(”Exception”);}catch(NullPointerExceptionnpe){System.out.println(”NullPointerException”);}}Whatistheresult?()
A.test
B.Exception
C.Compilationfails.
D.NullPointerException
第4题:
Compilation succeeds.
Compilation fails due to multiple errors.
Compilation fails due to an error only on line 20.
Compilation fails due to an error only on line 21.
Compilation fails due to an error only on line 22.
第5题:
0
null
Compilation fails.
A NullPointerException is thrown at runtime.
An ArrayIndexOutOfBoundsException is thrown at runtime.
第6题:
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?()
第7题:
collie
harrier
Compilation fails.
collie harrier
An exception is thrown at runtime.
第8题:
class TestA { public void start() { System.out.println(”TestA”); } } public class TestB extends TestA { public void start() { System.out.println(”TestB”); } public static void main(String[] args) { ((TestA)new TestB()).start(); } } What is the result?()
第9题:
r, t, t,
r, e, o,
Compilation fails.
An exception is thrown at runtime.
第10题:
test
null
An exception is thrown at runtime.
Compilation fails because of an error in line 1.
Compilation fails because of an error in line 4.
Compilation fails because of an error in line 5.