Computer Applications
Predict the output :
double n1 = Double.parseDouble("8.0");
double n2 = Double.parseDouble("2");
System.out.println(n1 + " " + n2);
Java
Java Library Classes
3 Likes
Answer
8.0 2.0
Working
parseDouble() converts String arguments passed to it into double data type. Thus, 8.0 will be assigned to n1 and 2.0 will be assigned to n2.
The values of n1 and n2 will be printed with a space " " between them.
Answered By
2 Likes
Related Questions
Find the error:
Integer obj = new Integer("A"); System.out.println(obj);Find the error :
double n2 = Double.parseDouble("2"); double n3 = Double.parseDouble("OCA"); System.out.println(n2 + " " + n3);What important is automatically happening in following code ?
long a = 124235L; Long b = new Long(a); long c = b.longValue(); System.out.println(c);Predict the output :
Integer c = 155; Integer d = 155; System.out.println(c == d); System.out.println(c.equals(d));