Multiple choice technology programming languages

What is the output of following block of program ? boolean var = false; if(var = true) { System.out.println(“TRUE”); } else { System.out.println(“FALSE”); }

  1. TRUE

  2. FALSE

  3. Compilation Error

  4. Run-time Error

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

The code uses assignment (=) instead of equality (==). In Java, var = true assigns true to var and returns true, so the condition is true and 'TRUE' is printed. This is a common mistake that compiles and runs but produces unexpected behavior.