Computer Applications
Find the error:
Integer obj = new Integer("A");
System.out.println(obj);
Java Library Classes
7 Likes
Answer
Integer obj = new Integer("A"); statement will generate NumberFormatException at the time of conversion of String argument "A" to Integer object. The exception is raised because "A" is not a valid string representation of a numeric value, therefore it cannot be converted to Integer object.
Answered By
4 Likes
Related Questions
Which methods return Wrapper class objects from primitive values ?
Predict the output.
int res = Integer.valueOf("100").compareTo(new Integer(100)); System.out.println(res);Find the error :
double n2 = Double.parseDouble("2"); double n3 = Double.parseDouble("OCA"); System.out.println(n2 + " " + n3);Predict the output :
double n1 = Double.parseDouble("8.0"); double n2 = Double.parseDouble("2"); System.out.println(n1 + " " + n2);