🎴 Flashcard Mode
JavaScript and Java Fundamentals Quiz
Card1 / 20
Mastered0
Review0
QuestionClick to flip
What is the output of following block of program ? boolean var = false; if(var = true) { System.out.println(“TRUE”); } else { System.out.println(“FALSE”); }
AnswerClick to flip back
A
TRUE
💡 Explanation:
The code uses assignment (=) not comparison (==). The statement if(var = true) assigns true to var, then evaluates the condition as true, so 'TRUE' is printed. This is a common bug where assignment is mistaken for equality check.