Ask Question
9 October, 11:45

Consider the following method. public double calculate (double x) { return x + 1.5; } The following code segment calls the method calculate in the same class. Double d1 = new Double (7.5); System. out. println (calculate (d1)); What, if anything, is printed when the code segment is executed? A. 8.0

B. 8.5

C. 9

D. 9.0

E. Nothing is printed because the code does not compile. The actual parameter d1 passed to calculate is a Double, but the formal parameter x is a double.

+1
Answers (1)
  1. 9 October, 13:29
    0
    E (Nothing is printed because the code will not compile)

    Explanation:

    There is a difference between Double which is a wrapper class and double which is data type. Changing the line Double d1 = new Double (7.5) to Double d1 = new (7.5) or simple declaring double d1 = 7.5 would have giving a printout of 9.0.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Consider the following method. public double calculate (double x) { return x + 1.5; } The following code segment calls the method calculate ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers