Question 411
double a = Math.pow(4, 3);
double b = Math.sqrt(81);
double c = Math.abs(-7.5);
double r = a - b * c;
What value is stored in r?Main Solution
Solution:
Answer: A. Math.pow(4, 3) = 64.0; Math.sqrt(81) = 9.0; Math.abs(-7.5) = 7.5. By Java's precedence, * binds tighter than -: 9.0 * 7.5 = 67.5, so r = 64.0 - 67.5 = -3.5. All three Math methods return double, so no promotion is required.
Answer: Correct: A
Answer images

