Developing Algorithms Using Arrays

AP Computer Science A· difficulty 1/5

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

What are the values of a and b after?

  • A

    a=9, b=5

    check_circle
  • B

    a=5, b=9

  • C

    a=5, b=5

  • D

    a=9, b=9

Explanation

The temp variable preserves a's value while it is overwritten by b.

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

Related questions