AP CSA Unit 1&2 Test
![Assessment](https://cf.quizizz.com/image/icons/quiz_solid_circle.png)
Assessment
•
Ashmit Grover
•
Computers
•
8th Grade - Professional Development
•
12 plays
•
Hard
Student preview
![quiz-placeholder](https://cf.quizizz.com/img/nuxt/adp-quiz-preview.webp)
25 questions
Show answers
1.
Multiple Choice
Consider the following code segment.
System.out.println("W");
System.out.println("X");
System.out.print("Y");
System.out.print("Z");
What is printed as a result of executing the code segment?
WXYZ
W
XYZ
WX
YZ
W
X
YZ
W
X
Y
Z
2.
Multiple Choice
Consider the following code segment.
int x = 10;
int y = 20;
/* missing code */
System.out.print(top / bottom);
Which of the following replacements for /* missing code */ will cause an ArithmeticException to occur?
I. int top = x - y;int bottom = y - x;
II.int top = 2 * x;int bottom = y - top;
III. int top = x + y;int bottom = 2 * top;
I. only
II. only
III. only
I. and II.
II. and III.
3.
Multiple Choice
Consider the following code segment.
String str = "AP";
str += "CS " + 1 + 2;
System.out.println(str);
What is printed as a result of executing the code segment?
CS AP12
AP CS3
CSAP 12
APCS 12
APCS 3
4.
Multiple Choice
Consider the following code segment.
String one = "ABC123";
String two = "C";
String three = "3";
System.out.println(one.indexOf(two));
System.out.println(one.indexOf(three));
System.out.println(two.indexOf(one));
What is printed when the code segment is executed?
2
5
-1
2
5
2
2
6
-1
3
6
-1
-1
-1
2
5.
Multiple Choice
Consider the following method.
public double calculate(double x)
{
return x + 1.5;
}
The following code segment calls the method calculate in the same class.
Double d1 = new Double(7.5);
System.out.println(calculate(d1));
What, if anything, is printed when the code segment is executed?
8.0
8.5
9
9.0
Nothing is printed because the code does not compile. The actual parameter d1 passed to calculate is a Double, but the formal parameter x is a double.
Explore all questions with a free account
Find a similar activity
Create activity tailored to your needs using
2nd-year set 2
![assessment](https://cf.quizizz.com/image/icons/quiz_solid_circle.png)
•
University
Arrays and Strings Revision
![assessment](https://cf.quizizz.com/image/icons/quiz_solid_circle.png)
•
9th - 12th Grade
AP CSA Unit 1 Intro
![assessment](https://cf.quizizz.com/image/icons/quiz_solid_circle.png)
•
12th Grade
AP CSA unit 1 - 4 TEST
![assessment](https://cf.quizizz.com/image/icons/quiz_solid_circle.png)
•
9th - 12th Grade
AP CSA Unit Review
![assessment](https://cf.quizizz.com/image/icons/quiz_solid_circle.png)
•
11th - 12th Grade
AP Computer Science Unit 1 Review
![assessment](https://cf.quizizz.com/image/icons/quiz_solid_circle.png)
•
11th Grade
AP_CSA Ch1
![assessment](https://cf.quizizz.com/image/icons/quiz_solid_circle.png)
•
9th - 12th Grade
AP CS A CH 1 Review
![assessment](https://cf.quizizz.com/image/icons/quiz_solid_circle.png)
•
10th - 12th Grade