What is the output of the following Java code?

ICSE Class 10 Computer Applications PYQ · 2025 Improvement · Section A

1(xiii)1 Mark · 2025 · Section A · 2025 Improvement

What is the output of the following Java code?

boolean flag = false; 
if (flag) { 
System.out.println("True"); 
} else { 
System.out.println("False"); 
}
Show SolutionHide Solution↓

False

Reason — The code declares a boolean variable flag with the value false, checks it in the if condition, and since it evaluates to false, the if block is skipped and the else block executes, printing False to the output.

← Previous questionNext question →

Browse the free Computer Applications sample bank