Computer Applications

Given: double m = Math.max(Math.ceil(14.55),15.5);
What will be the final value stored in the variable m?

  1. 15.0
  2. 14.0
  3. 15.5
  4. 14.5

Java Math Lib Methods

21 Likes

Answer

15.5

Reason — ceil() returns the whole number greater than or equal to the number and max() returns the greater number between its arguments. So, the expression is solved as follows:

    m = Math.max(Math.ceil(14.55),15.5);
⇒ m = Math.max(15.0,15.5);
⇒ m = 15.5

Answered By

11 Likes


Related Questions