Developing Algorithms Using Arrays

AP Computer Science A· difficulty 2/5

int a = 5, b = 9;
a = b;
b = a;

What are a and b after?

  • A

    a=5, b=9

  • B

    a=9, b=9

    check_circle
  • C

    a=9, b=5

  • D

    a=5, b=5

Explanation

Without a temporary, a's original value is lost; both end up equal to 9.

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

Related questions