Sorting

AP Computer Science A· difficulty 2/5

Integer x = 7;
Integer y = 4;
int r = x.compareTo(y);

What is the sign of r?

  • A

    positive

    check_circle
  • B

    undefined

  • C

    negative

  • D

    zero

Explanation

7 > 4, so compareTo returns a positive value.

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

Related questions