Choosing how to earn college credit? CLEP vs AP guide
| preferred AP College board partner for AP classes
medium Solved by 1 students

Halving Sequence

Mark
< Prev
Next >

A while loop divides an integer by two repeatedly until it is no longer greater than two.

What is printed when the following Java program is compiled and run?

public class QuestionTrace {

    public static void main(String[] args) {
        int x = 12;
        while (x > 2) {
            x = x / 2;
        }
        System.out.print(x);
    }
}
A

0

B

1

C

2

D

3

Did You Know?
Explain Why
Explain All Answers
Check Answer
Show Correct Answer
Report Question

Question Leaderboard

Not enough data yet to show leaderboard.

No comments yet. Be the first to comment!

AI Tutor

How can I help?

APFIVE © 2020.
Email: apfive@apfive.org|Instagram: @_apfive_|Privacy Policy|