πŸ“š

Β >Β 

πŸ’»Β 

Β >Β 

πŸ•Ή

4.6 MC Answers and Review

4 min readβ€’december 23, 2021

Dalia Savy

Dalia Savy

Dalia Savy

Dalia Savy


AP Computer Science AΒ πŸ’»

130Β resources
See Units

Answers and Review for Multiple Choice Practice on Iteration

https://firebasestorage.googleapis.com/v0/b/fiveable-92889.appspot.com/o/images%2F-l1YbZ5gWoP6I.png?alt=media&token=e553d9f2-7ca8-468b-bfd4-411cb9aafa05

Image Courtesy of Wikipedia.

β›”STOP!β›” Before you look at the answers make sure you gave this practice quiz a try so you can assess your understanding of the concepts covered in unit #. Click here for the practice questions: AP Comp Sci A Unit 4 Multiple Choice Questions.
Facts about the test: The AP Computer Science A exam has 40 multiple choice questions and you will be given 90 minutes to complete the section. That means it should take you around 34 minutes to complete 15 questions.

*The following questions were not written by CollegeBoard and although they cover information outlined in the AP Computer Science A Course and Exam Description the formatting on the exam may be different.


1. In programming, what is an iteration?
A. A decision point in a program
B. Testing a program to make sure it works
C. The repetition of steps in a program
D. The order that instructions are carried out in a program
Answer: The answer to this question is the simple definition of iteration.
πŸ“„ Study AP Comp Sci A, Unit 4.1: Unit 4 Overview and While Loops

2. In programming, why is iteration important or useful?
A. it allows code to be simplified by removing repeated steps
B. it guarantees that the code runs correctly
C. it determined the order that the steps of the code are carried out
D. it allows multiple paths through a program
Answer: Iteration is an abstraction or a way to simplify code.
πŸ“„ Study AP Comp Sci A, Unit 4.1: Unit 4 Overview and While Loops

3.Β  Which two statements are used to implement iteration?
A. WHILE and IF
B. FOR and WHILE
C. IF and ELSE
D. ELSE and WHILE
Answer: FOR and WHILE signify the use of iteration.
πŸ“„ Study AP Comp Sci A, Unit 4.1: Unit 4 Overview and While Loops

4. Which type of loop iterates until instructed otherwise?
A. FOR loop
B. Repeat-once loop
C. WHILE loop
D. A count-controlled loop
Answer: The WHILE loop is checked at the end, which will instruct the "otherwise" part, causing an end to the loop.
πŸ“„ Study AP Comp Sci A, Unit 4.1: Unit 4 Overview and While Loops

5. The condition for a WHILE loop to continue could be which of the following?
A. While something is true
B. While something is equal to something else
C. While something is greater than something else
D. All of the above
Answer: All are examples of checks for the WHILE loop.
πŸ“„ Study AP Comp Sci A, Unit 4.1: Unit 4 Overview and While Loops

6. What is the output for the following code?
https://firebasestorage.googleapis.com/v0/b/fiveable-92889.appspot.com/o/images%2F-agR6qDBZ1hjq.png?alt=media&token=dc937dca-9135-420b-a296-03904cb30fd7
A. 0 3 6 9 12
B. 12 9 6 3 0
C. 0 3 6 9
D. 9 6 3 0
Answer: Starts by printing 0 (eliminate 2 choices).. then increase by 3 in iteration, continue display until reaching 12 (but not including 12)
πŸ“„ Study AP Comp Sci A, Unit 4.1: Unit 4 Overview and While Loops

7.Β What is the output for the following code?
https://firebasestorage.googleapis.com/v0/b/fiveable-92889.appspot.com/o/images%2F-JYexeTFrBxgJ.png?alt=media&token=bc1a784f-a1c4-4dee-b9e4-5a8bcddd2042
A. Hello world! Β  Hello world! Β  Hello world! (repeated without end)
B. Hello World!
C. error
D. Hello, World
Answer: Set to true with no change to false to trigger leaving the iteration.
πŸ“„ Study AP Comp Sci A, Unit 4.1: Unit 4 Overview and While Loops

8. This causes a loop to terminate early
A. switch
B. continue
C. break
D. end
Answer: A break causes a loop to end early.
πŸ“„ Study AP Comp Sci A, Unit 4.1: Unit 4 Overview and While Loops

9. This type of loop has no way of ending and repeats until the program is interrupted.
A. infinite
B. indeterminate
C. interruptible
D. timeless
Answer: This is the definition of indeterminate loop.
πŸ“„ Study AP Comp Sci A, Unit 4.1: Unit 4 Overview and While Loops

10. What kind of variable controls the number of iterations performed by a loop?
A. repetition variable
B. accumulator
C. double
D. loop control variable
Answer: This is the definition of loop control variable.
πŸ“„ Study AP Comp Sci A, Unit 4.1: Unit 4 Overview and While Loops

11. What is the output of the following code fragment (selow)?
https://firebasestorage.googleapis.com/v0/b/fiveable-92889.appspot.com/o/images%2F-E04DuWUQAXW8.png?alt=media&token=5e175de9-9ba1-4801-b8e8-57b6eb291662
A. 2
B. 50
C. 75
D. 25
Answer: Loop won't run because x doesn't pass the condition (it is already > 0).
πŸ“„ Study AP Comp Sci A, Unit 4.2: For Loops

12. The "less than or equal to" comparison in Java is which of the following?
A. <<
B. <=
C. =<
D. <
Answer: This question tests your knowledge of Java notation.
πŸ“„ Study AP Comp Sci A, Unit 4.2: For Loops

13. If x is an integer and x = 1, what will be the value of x after the following loop terminates?Β 
https://firebasestorage.googleapis.com/v0/b/fiveable-92889.appspot.com/o/images%2F-NdpleiygQusq.png?alt=media&token=abc64c04-bfae-47c3-9a94-790438be6cc4
A. 2
B. 64
C. 100
D. 128
Answer: Will double until x=64*2=128.
πŸ“„ Study AP Comp Sci A, Unit 4.4: Nested Iteration

14. What would be printed out after the following code?Β 
https://firebasestorage.googleapis.com/v0/b/fiveable-92889.appspot.com/o/images%2F-nsxAVadX22W9.png?alt=media&token=35ad2b0d-eb9b-4bde-9b8c-bd555c9819c7
A. O
B. H
C. N
D. Y
Answer: Will display the character at the 5th, remember that location 1 is actually 0 location.
πŸ“„ Study AP Comp Sci A, Unit 4.3: Developing Algorithms Using Strings

15. What does equal ( ) return?
A. boolean
B. string
C. char
D. double
Answer: Will return type boolean.
πŸ“„ Study AP Comp Sci A, Unit 4.4: Nested Iteration

What can we help you do now?
πŸ”Study for Unit 5
🦘Jump to AP Comp Sci A Unit 5 Multiple Choice Questions
🀝Connect with other students studying AP Comp Sci A with Hours
Browse Study Guides By Unit
βž•Unit 1 – Primitive Types
πŸ“±Unit 2 – Using Objects
πŸ–₯Unit 3 – Boolean Expressions & if Statements
βš™οΈUnit 5 – Writing Classes
⌚️Unit 6 – Array
πŸ’ΎUnit 7 – ArrayList
πŸ’»Unit 8 – 2D Array
πŸ–²Unit 9 – Inheritance
πŸ–±Unit 10 – Recursion
πŸ™Exam Reviews