Vidyalelo
Java Programming · Q14

Exceptions

Programming · Java Programming · question 14

Q14

What is the result of the following code snippet?try String str = null; System.out.println(str.length()); catch (NullPointerException e) System.out.println("NullPointerException!"); catch (Exception e) System.out.println("Exception!");

A.
Compilation error
B.
No output
C.
Exception!
D.
NullPointerException!
Answer

Answer: Option D

Solution

Answer: Option D
No explanation is given for this question Let's Discuss on Board