Examveda
Examveda

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: Option D


This Question Belongs to Java Program >> Exceptions

Join The Discussion

Related Questions on Exceptions