Skip to main content

Unit 2 · Selection and Iteration

While Loops

While Loops MCQ Practice

Question 1 of 15

Answered 0 of 15

Choose one answer.

What is printed by the following code segment?

public class WhileLoopsContext
{
    public static void runExample()
    {
        int n = 3;
        while (n > 0)
        {
            System.out.print(n);
            n--;
        }
    }

    public static void main(String[] args)
    {
        runExample();
    }
}
Choose one answer.