What could be the output of this java code? - ProProfs Discuss
Advertisement

What could be the output of this java code?

Public static void parse(String str) { try { float f = Float.parseFloat(str); } catch (NumberFormatException nfe) { f = 0; } finally { System.out.println(f); } } public static void main(String[] args) { parse("invalid"); }

Asked by Wyatt Williams, Last updated: Mar 02, 2024

+ Answer
Request
Question menu
Vote up Vote down

2 Answers

krisz0629

krisz

krisz0629
Krisz

Answered Aug 05, 2020

A NumberFormatException is thrown by the parse method at runtime.

upvote downvote
Reply 

Wyatt Williams

Wyatt Williams

Wyatt Williams
Wyatt Williams

Answered Oct 30, 2017

Compilation fails.
upvote downvote
Reply 

Advertisement
Advertisement
Search for Google images Google Image Icon
Select a recommended image
Upload from your computer Loader
Image Preview
Search for Google images Google Image Icon
Select a recommended image
Upload from your computer Loader
Image Preview
Search for Google images Google Image Icon
Select a recommended image
Upload from your computer Loader

Email Sent
We have sent an email to your address "" with instructions to reset your password.