The output of the following code is:

ICSE Class 10 Computer Applications PYQ · 2025 Specimen · Section A

1(vi)1 Mark · 2025 · Section A · 2025 Specimen

The output of the following code is:

System.out.println(Math.ceil(6.4) + Math.floor(-1-2));
Show SolutionHide Solution↓

4.0

Reason — Let's evaluate the expression step by step:

System.out.println(Math.ceil(6.4) + Math.floor(-1 - 2));

Step 1: Evaluate Math.ceil(6.4)

  • The ceil method rounds a number up to the nearest integer.
  • Math.ceil(6.4) → 7.0 (as ceil returns a double).

Step 2: Evaluate -1 - 2

  • -1 - 2 = -3

Step 3: Evaluate Math.floor(-3)

  • Math.floor(-3): The floor method rounds a number down to the nearest integer.
  • Math.floor(-3) → -3.0 (as floor also returns a double).

Step 4: Add the Results

  • Math.ceil(6.4) + Math.floor(-3) → 7.0 + (-3.0)
  • Result = 4.0
← Previous questionNext question →

Browse the free Computer Applications sample bank