Q. 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!
πŸ’¬ Discuss
βœ… Correct Answer: (D) NullPointerException!

You must be Logged in to update hint/solution

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
99
Total Visits
πŸ“½οΈ
1 y ago
Published
πŸŽ–οΈ
Ranjeet
Publisher
πŸ“ˆ
96%
Success Rate