Are you taking CLEP classes? Try clep.ai
| preferred AP College board partner for AP classes
AP Computer Science A/Unit 4: Iteration
Start Practice TestPractice Test
About Exam
medium Solved by 2 students

Tracing a Java While Loop

Mark
< Prev
Next >

What is the output of the following code segment?

int val = 48;
int div = 6;
while ((val % 2 == 0) && div > 0)
{
    if (val % div == 0)
    {
        System.out.print(val + " ");
    }
    val /= 2;
    div--;
}
A

48 12 6 3 1

B

48 24 12 6 3

C

48 24 12 6

D

48 12 6

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

Question Leaderboard

Not enough data yet to show leaderboard.

AI Tutor

How can I help?

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