
AP CSA Unit 2 Test review
Authored by James Santiago
Computers
11th Grade
Used 3+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
34 questions
Show all answers
1.
MATCH QUESTION
30 sec • 5 pts
(int) (Math.random() * 11)
Integer 0-19, inclusive
(int) (Math.random()*100)
0.0 <= x < 10.0
(Math.random()*10)
Integer 0-99, inclusive
(int) (Math.random() * 11 + 1)
Integer 0-10, inclusive
(int) (Math.random() * 20)
Integer 1-11, inclusive
2.
MULTIPLE CHOICE QUESTION
30 sec • 5 pts
Consider the following code segment.
What is printed when the code segment is executed?
2
5
-1
2
5
2
2
6
-1
3
6
-1
-1
-1
2
3.
MULTIPLE CHOICE QUESTION
30 sec • 5 pts
The code segment below is intended to randomly print one of the values 2, 4, 6, or 8 with equal probability.
Which of the following can be used to replace /* missing code */ so that the code segment works as intended?
Math.random() * 4 + 1
Math.random() * 8
(int) (Math.random() * 4)
(int) (Math.random() * 4 + 1)
(int) (Math.random() * 8 + 1)
4.
MULTIPLE CHOICE QUESTION
30 sec • 5 pts
Consider the following code segment, which is intended to display 6.0.
Which of the following best describes the error, if any, in the code segment?
There are no errors and the code works as intended.
Either the numerator or the denominator of the fraction 1 / 2 should be cast as double.
The expression fact1 * fact 2 should be cast as double.
The expressions 1 / 2 and 3 * 4 should both be cast as double.
The variables fact1 and fact2 should both be declared as int.
5.
MULTIPLE CHOICE QUESTION
30 sec • 5 pts
String txt = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
What is the correct way to find the length of "txt" string?
int len = length(txt);
float len = txt.length();
int len = txt.length();
double len = length(txt);
6.
MULTIPLE CHOICE QUESTION
30 sec • 5 pts
System.out.println(1 + 2 + "3");
123
6
33
error
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
A standard way of visualizing the design of a program that displays class names, attributes, behaviors, and relationships to other classes is known as a(n):
Program Design Layout
Abstraction Model
UML Diagram
Class Hierarchy
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?