A

Admin • 828.03K Points
Coach

Q. What will be the output of following Java code?

Code:
public class Main {
public static void main(String arg[]) {
int i;
for (i = 1; i <= 12; i += 2) {
if (i == 8) {
System.out.println(i);
break;
}
}
}
}
  • (A) 1
  • (B) No output
  • (C) 8
  • (D) 1357911
  • Correct Answer - Option(B)
  • Views: 10
  • Filed under category Java
  • Hashtags:

Explanation by: Admin
The condition (i == 8) could not be satisfied hence nothing cannot be printed.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.