Chapter 2 Review

Chapter 2 Review

11th - 12th Grade

11 Qs

quiz-placeholder

Similar activities

1D Arrays

1D Arrays

9th Grade - University

14 Qs

JavaScript and Graphics

JavaScript and Graphics

9th - 12th Grade

15 Qs

Control Structures

Control Structures

12th Grade

10 Qs

Code.org Control Structures

Code.org Control Structures

12th Grade

10 Qs

APCS Printing and objects

APCS Printing and objects

9th Grade - University

10 Qs

Python Programming

Python Programming

5th Grade - University

15 Qs

P5.js Variables and Conditional Statements

P5.js Variables and Conditional Statements

9th - 12th Grade

15 Qs

JavaScript Graphics

JavaScript Graphics

9th - 12th Grade

10 Qs

Chapter 2 Review

Chapter 2 Review

Assessment

Quiz

11th - 12th Grade

Hard

Created by

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

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?