Developing Algorithms Using Arrays

AP Computer Science A· difficulty 4/5

To make a TRUE copy of an array (not a reference copy):

  • A

    Both B and C work

    check_circle
  • B

    int[] b = Arrays.copyOf(a, a.length);

  • C

    int[] b = a;

  • D

    int[] b = a.clone();

Explanation

Both clone() and Arrays.copyOf produce independent copies.

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

Related questions