AP CSA Semester 1 Review

Flashcard
•
Computers
•
9th - 12th Grade
•
Hard
Wayground Content
FREE Resource
Student preview

34 questions
Show all answers
1.
FLASHCARD QUESTION
Front
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?
Back
W
X
YZ
2.
FLASHCARD QUESTION
Front
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;
Back
II. only
3.
FLASHCARD QUESTION
Front
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?
Back
APCS 12
4.
FLASHCARD QUESTION
Front
What is printed when the following code segment is executed?
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));
Back
2
5
-1
5.
FLASHCARD QUESTION
Front
What is printed when the following code segment is executed?
public double calculate(double x)
{
return x + 1.5;
}
Double d1 = new Double(7.5);
System.out.println(calculate(d1));
Back
9.0
6.
FLASHCARD QUESTION
Front
The code segment below is intended to randomly print one of the values 2, 4, 6, or 8 with equal probability.
int val = /* missing code */ ;
val *= 2;
System.out.print(val);
Which of the following can be used to replace /* missing code */ so that the code segment works as intended?
Options: Math.random() * 4 + 1, Math.random() * 8, (int) (Math.random() * 4), (int) (Math.random() * 4 + 1), (int) (Math.random() * 8 + 1)
Back
(int) (Math.random() * 4 + 1)
7.
FLASHCARD QUESTION
Front
Consider the following code segment, which is intended to display 6.0.
double fact1 = 1 / 2;
double fact2 = 3 * 4;
double product = fact1 * fact2;
System.out.println(product);
Which of the following best describes the error, if any, in the code segment?
Options: 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.
Back
Either the numerator or the denominator of the fraction 1 / 2 should be cast as double.
Create a free account and access millions of resources
Similar Resources on Wayground
30 questions
Java Math and Misc (WU for VC 4)

Flashcard
•
10th - 12th Grade
25 questions
Semester Final TEST (proTWO)

Flashcard
•
10th Grade
23 questions
Java Loops

Flashcard
•
10th - 12th Grade
23 questions
AP CSA Unit One Review

Flashcard
•
11th Grade
36 questions
AP CS A Midterm Review

Flashcard
•
9th - 12th Grade
29 questions
AP CSA Unit 3 Boolean Expressions

Flashcard
•
10th - 12th Grade
30 questions
Java Loop Execution Flashcard disney

Flashcard
•
9th Grade - University
30 questions
Java Data Types Flashcard - Marvel

Flashcard
•
9th - 12th Grade
Popular Resources on Wayground
10 questions
Lab Safety Procedures and Guidelines

Interactive video
•
6th - 10th Grade
10 questions
Nouns, nouns, nouns

Quiz
•
3rd Grade
10 questions
Appointment Passes Review

Quiz
•
6th - 8th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
11 questions
All about me

Quiz
•
Professional Development
22 questions
Adding Integers

Quiz
•
6th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
20 questions
Grammar Review

Quiz
•
6th - 9th Grade
Discover more resources for Computers
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade
17 questions
[AP CSP] Binary Number System

Lesson
•
9th - 12th Grade
15 questions
1.1 Network Fundamentals Quiz

Quiz
•
10th Grade
20 questions
Understanding Information Processing Cycle

Quiz
•
10th Grade
19 questions
AP CSP Unit 1 Review (code.org)

Quiz
•
10th - 12th Grade