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 5 students

While Loop Execution Trace

Mark
< Prev
Next >

Consider the following mystery method.

public static int mystery(int n)
{
    int x = 1;
    int y = 1;
    
    // Point A
    
    while (n > 2)
    {
        x = x + y;
        
        // Point B
        
        y = x - y;
        n--;
    }
    
    // Point C
    
    return x;
}

Which of the following statements is true regarding the execution of this method?

A

x will never be 1 at // Point C.

B

n will always be greater than 2 at // Point B.

C

x will sometimes be 1 at // Point B.

D

n will sometimes be greater than 2 at // Point C.

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

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Total Time
Score
#1hitrishabhatia11 0m 00s 100
#2busemagngr11 0m 56s 44
#3hadleysmith501 0m 00s -10
#4meromaroseif12 1m 51s -21
#5y.seong202712 3m 44s -134
#6pandasiteitei11 3m 59s -139
Items per page:
10
1 – 6 of 6

AI Tutor

How can I help?

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