KnowledgeBoat Logo
|

Computer Applications

System.out.println(Math.round(Math.ceil(-8.8))); will result in:

  1. 8.0
  2. -8.0
  3. -9
  4. -8

Java

Java Math Lib Methods

7 Likes

Answer

-8

Reason — First, Math.ceil(-8.8) returns -8.0 because ceil() rounds a number up to the nearest integer (for negative numbers, “up” means closer to zero). Then, Math.round(-8.0) returns the integer -8, as round() converts a floating-point number to the nearest whole number.

Answered By

3 Likes


Related Questions