Question discussion

What is the output of the following Java program?public class Main { public static void main(String[] args) { for (int i = 0; i < 3; i++) S…

1532Medium DSSSB TGT Computer Science 0 replies 1 views
0

What is the output of the following Java program?

public class Main {
    public static void main(String[] args) {
        for (int i = 0; i < 3; i++) System.out.print(i * i + " ");
    }
}
  • A1 4 9
  • B0 1 4
  • C0 1 2
  • D1 2 3
Correct answer: B

Explanation

The loop prints the squares of 0, 1 and 2.

Discussion 0

Nobody has replied yet. Start the discussion!