Multiple choice technology programming languages

What will be the output of the below code snippet? public class Quiz4 { public static void main(String args[]) { int j = 0; for (int i = 0; i < 100; i++) j = j++; System.out.println(j); } }

  1. 99

  2. 0

  3. 100

  4. 101

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

The key issue is the post-increment operator j = j++. The post-increment operator returns the original value of j, then increments it. So j = j++ assigns the original value of j back to j, effectively doing nothing. After 100 iterations, j remains 0. Options A, C, and D are incorrect - they don't understand that the post-increment returns the original value before incrementing.