Multiple choice technology programming languages

What is the value of a? int a = 7; int b = 4; a = b; a = a + 1;

  1. 4

  2. 5

  3. 7

  4. 8

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The variable a is initially assigned 7, then reassigned to the value of b (which is 4), making a equal 4. Then a is incremented by 1, resulting in a final value of 5. The original value 7 is lost when a = b executes.