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!");
}

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!");
}
Correct Answer NullPointerException!

Related Questions

Comment on the output of the following C code.
#include int main(){ char *str = "This" //Line 1 char *ptr = "Program\n"; //Line 2 str = ptr; //Line 3 printf("%s, %s\n", str, ptr); //Line 4}