# Easy Multiple Choice QuestionsΒΆ

These problems are easier than most of those that you will usually see on the AP CS A exam.

6-7-1: What does the following code print?

for (int i = 3; i <= 12; i++)
{
System.out.print(i + " ");
}

• (A) 5 6 7 8 9
• What is i set to in the initialization area?
• (B) 4 5 6 7 8 9 10 11 12
• What is i set to in the initialization area?
• (C) 3 5 7 9 11
• This loop changes i by 1 each time in the change area.
• (D) 3 4 5 6 7 8 9 10 11 12
• The value of i starts at 3 and this loop will execute until i equals 12. The last time through the loop the value of i is 12.

6-7-2: How many times does the following method print a *?

for (int i = 3; i <= 9; i++)
{
System.out.print("*");
}

• (A) 9
• This would be true if i started at 0 and the value of i the last time through the loop it was 8.
• (B) 7
• How many numbers are between 3 and 9 (including 3 and 9)?
• (C) 6
• Since i starts at 3 and the last time through the loop it is 9 the loop executes 7 times (9 - 3 + 1 = 7)
• (D) 10
• This would be true if i started at 0 and ended at 9. Does it?

6-7-3: What does the following code print?

int x = -5;
while (x < 0)
{
x++;
System.out.print(x + " ");
}

• (A) 5 4 3 2 1
• x is initialized (set) to -5 to start.
• (B) -5 -4 -3 -2 -1
• x is incremented (x++) before the print statement executes.
• (C) -4 -3 -2 -1 0
• x is set to -5 to start but then incremented by 1 so it first prints -4.
Next Section - Medium Multiple Choice Questions