Question: What will be the output of the following code snippet? try { String name = null; System.out.printf(The length of the string is - %d, name.length());

What will be the output of the following code snippet?

try {
String name = null;
System.out.printf("The length of the string is - %d", name.length());
}
catch (RuntimeException e) 

{
System.out.printf("Runtime Exception");
}
catch (NullPointerException e) 

{
System.out.println("Null Pointer Exception");
}

Step by Step Solution

3.34 Rating (157 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The output of this code snippet will be Null Pointer Exception Heres why The ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Java How To Program Late Objects Questions!