LogiQuest
Back to Flow Control
16

What is the output of the following program?

public class Main {
    public static void main(String[] args) {
        int sum = 0;
        for (int v : new int[]{1, 2, 3, 4}) {
            if (v % 2 == 0) sum += v;
        }
        System.out.println(sum);
    }
}
Easy

Discussion (0)

  • No discussion yet. Ask a doubt or share a shortcut.

Log in to join the discussion.