wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

AP CSA Unit 1 Review

Total questions: 20

Worksheet time: 10mins

Name
Class
Date
1.

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?

a)

WXYZ

b)

W

XYZ

c)

WX

YZ

d)

W

X

YZ

e)

W

X

Y

Z

2.

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?

a)

CS AP12

b)

AP CS3

c)

CSAP 12

d)

APCS 12

e)

APCS 3

3.

What is the expected output?

a)

-1

b)

0

c)

1

d)

17

e)

18

4.

Which of these are escape characters? Choose all that apply!

a)

\n

b)

\t

c)

\

d)

"

e)

/

5.

Is the following identifier legal or illegal?

MyFirstProgram

a)

legal

b)

illegal

6.

If x = 4, x++ =?

a)

16

b)

8

c)

5

d)

3

7.

if int a = 10, what does b = if b= 15/4

a)

1

b)

5

c)

0

d)

3

8.

In integer division, what happens to the decimal, such as int a = 25/10, where the answer would be 2.5?

a)

the decimal is dropped

b)

the number is rouneded

c)

the program gives you an error

d)

only the decimal is returned

9.

Which of the following are primitive data types? (slect all that are)

a)

int

b)

float

c)

String

d)

triple

10.

T/F? String is a primitive data type?

a)

true

b)

false

11.

In our program, we need to track whether or not the score is 0 or not. What variable type can we use?

a)

int

b)

double

c)

String

d)

boolelan

12.

What is %

a)

percentage

b)

negation

c)

modulus, like division but the remainder is the answer

d)

inverse

13.

if x = 5, what is x +=30?

a)

-25

b)

0

c)

35

d)

5.30

14.


What is the code for this output?

a)
b)
c)
d)
15.

What is the code for this output?

a)
b)
c)
d)
16.

What is the code for this output?

a)
b)
c)
d)
17.

What will be the output of this code?

a)
b)
c)
d)
18.

What is the code for this output?

a)
b)
19.

What is the code for this output?

a)
b)
c)
20.

What is the code for this output?

a)
b)