Home / Questions / What are the values stored in variables r1 and r2: double r1 = Math.abs(Math.min(-2.83, -5.83)); double r2 = Math.sqrt(Math.floor(16.3));
Explanatory Question

What are the values stored in variables r1 and r2:

  1. double r1 = Math.abs(Math.min(-2.83, -5.83));
  2. double r2 = Math.sqrt(Math.floor(16.3));

👁 92 Views
📘 Detailed Answer
🕒 Easy to Read
Read the answer carefully and go through the related questions on the right side to improve your understanding of this topic.

Answer with Explanation

  1. r1 has 5.83
  2. r2 has 4.0
Explanation
  1. Math.min(-2.83, -5.83) returns -5.83 as -5.83 is less than -2.83. (Note that these are negative numbers). Math.abs(-5.83) returns 5.83.
  2. Math.floor(16.3) returns 16.0. Math.sqrt(16.0) gives square root of 16.0 which is 4.0.