Computer Applications
What is the output of the following Java code?
boolean flag = false;
if (flag) {
System.out.println("True");
} else {
System.out.println("False");
}
- True
- False
- No output
- Compilation error
Java
Java Operators
5 Likes
Answer
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.
Answered By
2 Likes
Related Questions
Which of the following is not a type of token in Java?
1. Method 3. Literal 2. Identifier 4. Keyword - only 1
- 1 and 3
- only 2
- only 4
The statement given below is termed as:
public void Accept(int a)- Method signature
- Method block
- Method prototype
- Constructor
Identify the static method from the list given below:
- length()
- nextLine()
- substring(int)
- isLetter(char)
Which one of the following will be the output of the below statements?
String a[]={"Rohini", "Rajarshi", "Rajeev", "Rehan", "Rebecca"}; System.out.println(a[2].substring(2));- jeev
- Ra
- Raj
- je