ICSE Class 10 Computer Applications
Question 4 of 16
Using Library Classes — Question 4
Back to all questions 4
Question Question 4
When do the numeric wrapper class constructors raise NumberFormatException ?
The numeric wrapper class constructors may raise NumberFormatException at the time of conversion of String arguments to primitive data types. The exception is raised when the String argument cannot be converted to the desired data type.
For example,
int val = Integer.parseInt("A");Here, the String argument "A" cannot be converted to int type and therefore, NumberFormatException is thrown.