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
Зарегистрируйся сейчас
или Подпишись на будущие тесты