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

Which of the following is true of method mystery?

Consider the following 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 is true of method mystery?

A

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

B

x will never be 1 at // Point C.

C

x will sometimes be 1 at // Point B.

D

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

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

Question Leaderboard

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

AI Tutor

How can I help?

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