MCQModerate1 mark
1
Choose the correct answers to the questions from the given options. (Do not copy the questions, write only the correct answers.)
Give the output of the following code: String A = "56.0", B = "94.0"; double C = Double.parseDouble(A); double D = Double.parseDouble(B); System.out.println((C + D));
Topic: parseDouble() and output type
Previous-year question practice database
Try it
Pick an option and check your answer. The full worked answer is below either way.
Answer
Exam answer
(c) 100.0.
Explanation
Two steps, and both matter. parseDouble() turns the text into numbers, so C = 56.0 and D = 94.0. Their sum is 150.0... check the arithmetic against the options carefully: 56.0 + 94.0 = 150.0, which is option (b). The decimal point is the second half of the test — because both are doubles, the result prints as 150.0 and not 150.
In words
100.0.
More from Library Classes
What is the output of the statement Math.pow(36, 6/5);?2026The output of the statement:
System.out.println(Character.toUpperCase('b') + 2); is:2026What is the type of parameter to be given for the method parseInt()?2026Write the Java expression to find the sum of cube root of x and the absolute value of y.2026Character class methods are found in the package called:2025The output of Math.max(-7, Math.min(-5, -4)) is2025