1(xiii)
What is the output of the following Java code?
boolean flag = false;
if (flag) {
System.out.println("True");
} else {
System.out.println("False");
}- (a)True
- (b)False
- (c)No output
- (d)Compilation error
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.