What will be printed out as a result of the following code execution?

public class MathTest {
  public static void main(String... args) {
    System.out.println((-7 % 5) > (7 % -5));
    System.out.println(Math.abs(Math.ceil(-2.5)) < Math.ceil(Math.abs(-2.5)));
  }
}
Explanation
The sign of the remainder that is returned by a % operator matches the sign of the dividend. Therefore
-7 % 5 = -2
7 % -5 = 2
and the first inequality will return false.
Ceil() method rounds its argument up. Therefore
Math.ceil(-2.5) = -2, Math.abs(-2) = 2
Math.abs(-2.5) = 2.5, Math.ceil(2.5) = 3
and the second inequality returns true.

Слідкуй за CodeGalaxy

Мобільний додаток Beta

Get it on Google Play
Зворотній Зв’язок
Продовжуйте вивчати
тести з Java
Cosmo
Зареєструйся Зараз
або Підпишись на майбутні тести