A

Admin • 828.03K Points
Coach

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
  • Correct Answer - Option(C)
  • Views: 14
  • Filed under category Java
  • Hashtags:

Explanation by: Admin
Since x is between 5 and 20, the else block is executed and “x is between 5 and 20” is

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.