Using the Math Class

AP Computer Science A· difficulty 2/5

int x = Math.abs(-7);
System.out.println(x);

What is printed?

  • A

    7

    check_circle
  • B

    -7

  • C

    0

  • D

    1

Explanation

Math.abs returns the absolute value of its argument, so Math.abs(-7) returns 7.

Want 10 more like this — adaptive to your weak spots?

Related questions