Home / Programming MCQs / JAVA MCQs / Question

R

Ram Sharma • 178.09K 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
Explanation by: Team MCQ Buddy
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.