Sorting

AP Computer Science A· difficulty 2/5

String a = "cat";
String b = "cat";
int r = a.compareTo(b);

What is r?

  • A

    3

  • B

    0

    check_circle
  • C

    1

  • D

    -1

Explanation

Equal strings yield 0 from compareTo.

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

Related questions