Developing Algorithms Using Arrays

AP Computer Science A· difficulty 4/5

<code>void replace(int[] arr) { arr = new int[10]; }</code> — caller's array

  • A

    Throws exception

  • B

    Unchanged (parameter is local; reassigning doesn't affect caller)

    check_circle
  • C

    Replaced with new

  • D

    Becomes null

Explanation

Pass-by-value: reassigning the parameter doesn't change the caller.

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

Related questions