
AP CA A Unit 4 Review
Authored by Sammi McConnell
Computers
11th - 12th Grade
Used 75+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
About
This AP Computer Science A Unit 4 review quiz focuses on iteration and control structures in Java programming, targeting high school students in grades 11-12 who are enrolled in an Advanced Placement computer science course. The questions comprehensively assess students' understanding of for loops, while loops, nested loops, string manipulation, boolean logic with short-circuit evaluation, and the Math.random() method. Students need to demonstrate proficiency in tracing code execution, predicting output, analyzing loop conditions, understanding modular arithmetic, and recognizing infinite loop scenarios. The core concepts require students to mentally execute code step-by-step, understand how loop variables change with each iteration, comprehend string indexing and substring operations, and apply mathematical operations within programming contexts. These skills demand both procedural thinking and the ability to analyze complex algorithmic patterns. Created by Sammi McConnell, a Computers teacher in the US who teaches grades 11 and 12. This comprehensive review quiz serves multiple instructional purposes, functioning effectively as a formative assessment tool to gauge student readiness before the AP exam, homework reinforcement for recently taught iteration concepts, or intensive review material during exam preparation periods. Teachers can utilize individual questions as warm-up problems to start class discussions about specific programming concepts, or deploy the entire quiz as a timed practice session that mirrors AP exam conditions. The varied question formats, including multiple-choice and code analysis problems, align with College Board standards for AP Computer Science A, particularly focusing on Unit 4 learning objectives related to iteration (for loops, while loops, nested loops) and Unit 3 objectives covering boolean expressions and if statements, directly supporting the AP CSA curriculum framework standards CRD-2, AAP-2, and AAP-3.
Content View
Student View
20 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
What is output to the screen by the following code?
2 1 0 3 2 1 0 3 2 1
1 0 3 2 1 0 3 2 1 0
1 0 3 2 1 0 3 2 1
1 2 3 0 1 2 3 0 1 2
Answer explanation
This has the correct number of iterations and the correct pattern
2.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Assuming that s is a correctly initialized String (that does not end in a space) which of the following best describes what the algorithm below does?
Prints the number of times a space appears in str.
Prints the character after each space in str.
Prints the character before each space in str
Prints each character in str followed by a space.
Answer explanation
The indexOf function returns the index of the first appearance of a character. For each iteration the character in str after this is printed, then str is replaced by everything after that space. This continues until indexOf (“ “) returns -1 when there are no spaces left
3.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
What is output by the following code?
saopmoee
saompoeel
aspoomee
Nothing is printed because there is an out of bounds error
Answer explanation
The code iterates forwards through str1 (“awesome”) starting at s and backwards through str2 (“leopard”) starting at a. It starts printing a character from str1 then str2 going back and forth until st1 runs out of letters in which case the loop ends.
4.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Which of the following statements will return a random odd number between 5 and 15 inclusive?
2 * (int) (6 * Math.random()) + 5
2 * (int) (6 * Math.random() + 5)
(int) (2 * 5 * Math.random() + 5)
2 * (int) (5 * Math.random()) + 5
Answer explanation
This is correct. The Math.random() method returns a random double between 0, inclusive and 1 exclusive. Therefore 6 * Math.random() will return a random double which is greater than or equal to 0 and smaller than 6. When this is cast to an int, the nearest integer value below will be returned. Therefore (int) (6 * Math.random()) will be an int between 0 and 5 inclusive. Multiplying this by 2 ensures every other number is printed: 2 * (int) (6 * Math.random()) returns a random number between 0, 2, 4, 6, 8 or 10 inclusive, and then shifting by 5 creates the values 5, 7, 9, 11, 13, 15
5.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Set the following for loop header so that it prints the numbers, 10 5 0 -5 -10.
10, > -10, -= 5
10, >= -10, -= 5
-10, <= 10, ++
10, > 10, -= 5
Answer explanation
i starts as 10, decreases by 5 each time, and no longer runs once the value of i is less than -10, so 10 5 0 -5 and -10 are printed
6.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
What does short circuit evaluation mean in the following code?
if a >= b is false it evaluates c != d
if a >= b is false it doesn't evaluate c != d
if a >= b is true it evaluates c != d
c != d is evaluated first, and if true it evaluates a >= b
Answer explanation
This is correct and is how short circuit evaluations works in an && expression (Short-circuit evaluation means that when evaluating boolean expressions (logical AND and OR ) you can stop as soon as you find the first condition which satisfies or negates the expression.)
-Explanation of why option if a >= b is true it evaluates c != d is wrong: Even though this is true, it does not represent short circuit evaluation and how it works.
7.
MULTIPLE SELECT QUESTION
1 min • 1 pt
For which of the following replacements for /* missing condition */ will the segment result in an infinite loop? (May choose more than one)
I. a > 0
II. a == 12
III. a % 3 != 5
Answer explanation
Both of these conditions will result in an infinite loop
I - Since a starts at 5, which is great than 0, and because a is increased each time through the loop, it will always be greater than 0, this will result in an infinite loop, but it is not the only condition to cause an infinite loop
II - This will actually result in a loop that never runs
III - Since a value of a % 3 can only equal 0, 1 or 2, regardless of what the value of a is increased to, it will never equal 5, so the loop will always run, but is is not the only condition to cause an infinite loop
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?
Similar Resources on Wayground
15 questions
Начала программирования на языке Паскаль
Quiz
•
8th - 11th Grade
15 questions
REVISION-Primary & Secondary Storage
Quiz
•
10th - 11th Grade
20 questions
Online Platform Block Q
Quiz
•
11th - 12th Grade
15 questions
Chapter 3: Storage devices and media (Part 2):
Quiz
•
10th - 11th Grade
20 questions
City & Guilds Award in Business Processes
Quiz
•
12th Grade
15 questions
emptech L1 A
Quiz
•
12th Grade
20 questions
ตอบปัญหาคอมพิวเตอร์st
Quiz
•
9th - 12th Grade
15 questions
Ôn tập kỳ 2 tin 6
Quiz
•
1st - 12th Grade
Popular Resources on Wayground
15 questions
Fractions on a Number Line
Quiz
•
3rd Grade
10 questions
Probability Practice
Quiz
•
4th Grade
15 questions
Probability on Number LIne
Quiz
•
4th Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
22 questions
fractions
Quiz
•
3rd Grade
6 questions
Appropriate Chromebook Usage
Lesson
•
7th Grade
10 questions
Greek Bases tele and phon
Quiz
•
6th - 8th Grade