KnowledgeBoat Logo
|

Computer Applications

The output of Math.round(6.6) + Math.ceil(3.4) is:

  1. 9.0
  2. 11.0
  3. 10.0
  4. 11

Java Math Lib Methods

ICSE Sp 2024

35 Likes

Answer

11.0

Reason — The given expression is evaluated as follows:
Math.round(6.6) + Math.ceil(3.4)
⇒ 7 + 4.0
⇒ 11.0

Math.round() rounds off its argument to the nearest mathematical integer and returns its value as an int or long type. Math.ceil method returns the smallest double value that is greater than or equal to the argument and is equal to a mathematical integer. In the addition operation, the type of result is promoted to a double as one operand is double. Hence, the result is 11.0.

Answered By

19 Likes


Related Questions