Scope and Access

AP Computer Science A· difficulty 4/5

<code>Dog a = new Dog(); Dog b = a; b = null;</code> — what is <code>a</code>?

  • A

    Still references the original Dog

    check_circle
  • B

    Garbage collected

  • C

    Compile error

  • D

    null

Explanation

<code>b = null</code> only affects b's reference; a still points to the Dog.

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

Related questions