| preferred AP College board partner for AP classes
AP Computer Science A/Unit 4: Iteration
Start Practice TestPractice Test
Share
About Exam
medium Solved by 2 students
Tracing a Java While Loop
< Prev
Next >

Consider 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--;
}

What is printed when the code segment is executed?

A

48 24 12 6

B

48 24 12 6 3

C

48 12 6 3 1

D

48 12 6

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

Question Leaderboard

Not enough data yet to show leaderboard.

AI Tutor

How can I help?

APFIVE © 2020.
Email: [email protected]|Privacy Policy