Q. What is the output of the following code?

Code:
int x = 10;
if (x < 5) {
System.out.println(“x is less than 5”);
} else if (x > 20) {
System.out.println(“x is greater than 20”);
} else {
System.out.println(“x is between 5 and 20”);
}
  • (A) x is less than 5
  • (B) x is greater than 20
  • (C) x is between 5 and 20
  • (D) Compiler error
πŸ’¬ Discuss
βœ… Correct Answer: (C) x is between 5 and 20
Explanation: Since x is between 5 and 20, the else block is executed and “x is between 5 and 20” is
Explanation by: Deepak Sahoo
Since x is between 5 and 20, the else block is executed and “x is between 5 and 20” is

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
358
Total Visits
πŸ“½οΈ
3 y ago
Published
πŸŽ–οΈ
Deepak Sahoo
Publisher
πŸ“ˆ
95%
Success Rate