Are you taking CLEP classes? Try clep.ai
| preferred AP College board partner for AP classes
medium Solved by 4 students

While Loop Execution Trace

< 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
Mark for review

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Total Time
Score
#1hitrishabhatia11 0m 00s 100
#2hadleysmith501 0m 00s -10
#3meromaroseif12 1m 51s -21
#4y.seong202712 3m 44s -134
#5pandasiteitei11 3m 59s -139
Items per page:
10
1 – 5 of 5
No comments yet. Be the first to comment!

AI Tutor

How can I help?

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