wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

String and Math Methods AP CSA

Total questions: 10

Worksheet time: 21mins

Name
Class
Date
1.
a)

ABCD

b)

BCDE

c)

BCEF

d)

BCDEF

e)

ABCDEF

2.
a)

3

b)

4

c)

5

d)

6

e)

7

3.

Consider the following code segment.

What is printed when the code segment is executed?

a)

comp

b)

c o m p

c)

comp com co c

d)

comp omp mp p

e)

comp comp comp comp

4.

Consider the following code segment.

What is the value of num when the code segment is executed?

a)

3

b)

4

c)

5

d)

6

e)

7

5.

Use the image for the question.

a)

b)

c)

d)

e)

6.

Which of the following statements assigns a random integer between 1 and 10, inclusive, to rn ?

a)

b)

c)

d)

e)

7.

Consider the following code segment, which is intended to assign to num a random integer value between min and max, inclusive. Assume that min and max are integer variables and that the value of max is greater than the value of min.

Which of the following could be used to replace /* missing code */ so that the code segment works as intended?

a)

b)

c)

d)

e)

8.

Consider the following code

What is printed as a result of exectuting the code segment?

a)

operation goes well

b)

15

c)

ation goes well

d)

7

e)

the operation goes well

9.

Consider the following code segment.

What is printed as a result of executing the code segment?

a)

bye

b)

3

c)

dbye

d)

2

e)

odbye

10.

Consider the following code segment

What is output to the console when this code segment is executed?

a)

12.0

b)

6.0

c)

-0.7

d)

-6.0

e)

-12.0