What is the result of the following program:

public class Foo {
    public static void main(String[] args) {
        for (int k = 1; k <= 10; k++) {
            if (k % 5 == 0) break label;
            System.out.print(k + " ");
        }

    label:
        {
            System.out.print("stop!");
        }
    }
}
Explanation
Compilation completed with errors.
Labels (label) is used in conjunction with a break (or continue) to exit (or skip iteration) in cycle for, while, do-while, to which this break (continue) applies.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Keep exploring
Java quizzes
Cosmo
Sign Up Now
or Subscribe for future quizzes