
Chapter 2 Review
Authored by Samuel Keener
11th - 12th Grade
Used 66+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
11 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
The code segment below is intended to calculate the circumference c of a circle with the diameter d of 1.5. The circumference of a circle is equal to its diameter times pi.
/* missing declarations */
c = pi * d;
Which of the following variable declarations are most appropriate to replace /* missing declarations */ in this code segment?
int pi = 3.14159;
int d = 1.5;
final int c;
final int pi = 3.14159;
int d = 1.5;
int c;
final double pi = 3.14159;
double d = 1.5;
double c;
double pi = 3.14159;
double d = 1.5;
final double c = 0.0;
final double pi = 3.14159;
final double d = 1.5;
final double c = 0.0;
2.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Consider the following code segment.
int x = 5;
int y = 6;
/* missing code */
z = (x + y) / 2;
Which of the following can be used to replace /* missing code */ so that the code segment will compile?
I. int z = 0;
II. int z;
III. boolean z = false;
I ONLY
II ONLY
I AND II ONLY
II AND III ONLY
I, II, AND III
3.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Consider the following code segment.
int a = 5;
int b = 8;
int c = 3;
System.out.println(a + b / c * 2);
What is printed as a result of executing this code?
2
6
8
9
14
4.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
The following code segment is intended to interchange the values of the int variables x and y. Assume that x and y have been properly declared and initialized.
int temp = x;
/* missing code */
Which of the following can be used to replace /* missing code */ so that the code segment works as intended?
x = y;
x = temp;
x = y;
y = temp;
y = x;
x = temp;
y = x;
temp = y;
y = x;
temp = x;
5.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Consider the following code segment, which is intended to print the digits of the two-digit int number num in reverse order. For example, if num has the value 75, the code segment should print 57. Assume that num has been properly declared and initialized.
/* missing code */
System.out.print(onesDigit);
System.out.print(tensDigit);
Which of the following can be used to replace /* missing code */ so that the code segment works as intended?
int onesDigit = num % 10;
int tensDigit = num / 10;
int onesDigit = num / 10;
int tensDigit = num % 10;
int onesDigit = 10 / num;
int tensDigit = 10 % num;
int onesDigit = num % 100;
int tensDigit = num / 100;
int onesDigit = num / 100;
int tensDigit = num % 100;
6.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Which of the following expressions evaluate to 7 ?
I.9 + 10 % 12
II. (9 + 10) % 12
III. 9 – 2 % 12
I ONLY
II ONLY
I AND III
II AND III
I, II, AND III
7.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Consider the following code segment.
int a = 5;
int b = 4;
int c = 2;
a *= 3;
b += a;
b /= c;
System.out.print(b);
What is printed when the code segment is executed?
2
4
9
9.5
19
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
Rich/ poor vocabulary quiz
Quiz
•
12th Grade
10 questions
NBA quiz 2020
Quiz
•
9th - 12th Grade
13 questions
Anime 99
Quiz
•
9th Grade - Professio...
10 questions
MODULE 3
Quiz
•
11th Grade
16 questions
LIKE AND DON'T LIKE VIDEO QUIZ
Quiz
•
12th Grade
15 questions
Sumatif PP Kls 9 Smt 2 Bab 4
Quiz
•
9th Grade - University
10 questions
INDEX NUMBER
Quiz
•
12th Grade
15 questions
4.6.4 Logic Gates
Quiz
•
10th Grade - Professi...
Popular Resources on Wayground
15 questions
Fractions on a Number Line
Quiz
•
3rd Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
54 questions
Analyzing Line Graphs & Tables
Quiz
•
4th Grade
22 questions
fractions
Quiz
•
3rd Grade
20 questions
Main Idea and Details
Quiz
•
5th Grade
20 questions
Context Clues
Quiz
•
6th Grade
15 questions
Equivalent Fractions
Quiz
•
4th Grade
Discover more resources for
20 questions
-AR -ER -IR present tense
Quiz
•
10th - 12th Grade
15 questions
Making Inferences
Quiz
•
7th - 12th Grade
15 questions
Main Idea and Supporting Details.
Quiz
•
4th - 11th Grade
12 questions
Add and Subtract Polynomials
Quiz
•
9th - 12th Grade
7 questions
How James Brown Invented Funk
Interactive video
•
10th Grade - University
15 questions
Atomic Habits: Career Habits
Lesson
•
9th - 12th Grade
16 questions
ACT English - Grammar Practice #2
Quiz
•
11th Grade
20 questions
Banking
Quiz
•
9th - 12th Grade