Chapter 2 Review

Quiz
•
11th - 12th Grade
•
Hard
Samuel Keener
Used 66+ times
FREE Resource
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
Create a free account and access millions of resources
Similar Resources on Wayground
11 questions
Casting in Java

Quiz
•
9th - 12th Grade
15 questions
CP M4 Repetition & Loops

Quiz
•
9th - 12th Grade
10 questions
2.2.1 (d) Variables

Quiz
•
12th Grade
13 questions
Unit 4 AP CSA Review

Quiz
•
12th Grade
10 questions
Quiz 16 - Arrays and Loops

Quiz
•
11th Grade
12 questions
Python - Conditionals

Quiz
•
9th - 12th Grade
15 questions
แบบทดสอบก่อนเรียน การเขียนโปรแกรม

Quiz
•
12th Grade
13 questions
APCSA Unit 3 Review

Quiz
•
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
20 questions
Lab Safety and Lab Equipment

Quiz
•
9th - 12th Grade
20 questions
Getting to know YOU icebreaker activity!

Quiz
•
6th - 12th Grade
6 questions
Secondary Safety Quiz

Lesson
•
9th - 12th Grade
13 questions
8th - Unit 1 Lesson 3

Quiz
•
9th - 12th Grade
28 questions
Ser vs estar

Quiz
•
9th - 12th Grade
16 questions
Metric Conversions

Quiz
•
11th Grade
21 questions
SPANISH GREETINGS REVIEW

Quiz
•
9th - 12th Grade
6 questions
PRIDE Always and Everywhere

Lesson
•
12th Grade