117k views
4 votes
What does this method do?

void mystery()
{
turnLeft();
turnLeft();
turnLeft();
}

A) Turns Right
B) Turns West
C) Turns Around
D) Completes a circle and faces the same direction

1 Answer

2 votes

Final answer:

The method mystery() instructs an object to perform three left turns, each presumably 90 degrees, which cumulatively result in the object turning right by 90 degrees.

Step-by-step explanation:

The method described in the question is a simple control method often found in programming exercises related to robotics or simulations.

The mystery() method executes the turnLeft() command three times consecutively. Since one turnLeft() usually signifies a 90-degree turn to the left, performing this action three times would result in a 270-degree turn.

This effectively is the same as turning right by 90 degrees or one quarter-turn clockwise without actually including a turnRight() command. Thus, the correct answer to what this method does is: A) Turns Right.

User Nfmcclure
by
8.4k points