What is value of x?

ICSE Class 10 Computer Applications PYQ · 2024 Paper · Section A

2(v)1 Mark · 2024 · Section A · 2024 Paper
String s1 = "45.50"; String s2 = "54.50";
double d1=Double.parseDouble(s1);
double d2=Double.parseDouble(s2);
int x= (int)(d1+d2);

What is value of x?

Show SolutionHide Solution↓

100

Reason — The code converts the strings "45.50" and "54.50" into doubles using Double.parseDouble(), resulting in d1 = 45.5 and d2 = 54.5. Their sum is 100.0.
Casting 100.0 to an integer using (int) removes the decimal part, leaving x = 100.

← Previous questionNext question →

Browse the free Computer Applications sample bank