Variables and Data Types

AP Computer Science A· difficulty 4/5

int a = 5;
int b = a;
a = 10;
System.out.println(b);

What is printed?

  • A

    5

    check_circle
  • B

    10

  • C

    0

  • D

    15

Explanation

Primitive assignment copies the value; b stores 5 independently of a, so changing a does not affect b.

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

Related questions