wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Computer Science Unit 3 Test

Total questions: 15

Worksheet time: 30mins

Name
Class
Date
1.

What is the difference between System.out.print and System.out.println

a)

.print will give an error

b)

.println will give an error

c)

.println will start a new line after your message

d)

print will start a new line

2.

int x = 5;

int y = 4;

double z = x/y; What will z be set to?

a)

1.0

b)

1

c)

1.25

d)

Error

3.

double a = 5;

double b = 3;

int c = a/b; What will c be set to?

a)

Error

b)

1.66666...

c)

1

d)

1.0

4.

int a = 9;

double b = 10;

double c = a/b; What will c be set to?

a)

0.9

b)

0

c)

1.1111...

d)

Error

5.

int x = 10;

int y = 55;

System.out.print("a" + x + y); //What will this line output?

a)

axy

b)

a1055

c)

a65

d)

65

6.

int x = 10;

int y = 55;

System.out.print("a" + (x + y)); //What will this line output?

a)

axy

b)

a1055

c)

a65

d)

65

7.

int a = 3;

int b = 4;

double c = Math.pow(a, b); What will c be set to?

a)

81

b)

64

c)

12

d)

7

8.

int a = 49;

double g = Math.sqrt(a);

What will g be set to?

a)

7

b)

9

c)

Error

d)

e49e^{49}

9.

int x = 7;

int y = 5;

System.out.print(x + y + "z"); //What will this line output?

a)

xyz

b)

12z

c)

75z

d)

z75

10.

double a = 6.0;

int b = (int)a/4

What will b be set to?

a)

1.5

b)

1

c)

0.6666...

d)

Error

11.

int a = 4;

int b = 3;

double c = (double)b/a

a)

0.75

b)

0

c)

1

d)

Error

12.

int page = (int)(Math.random() * 500) +1

What are possible values of page?

a)

Between 1 and 500 (inclusive)

b)

Between 0 and 1 (excluding 1)

c)

Between 0 and 500 (inclusive)

d)

Any number

13.

Which of these adds 5 to the value of x?

a)

x =+ 5

b)

x = 5

c)

x += 5

d)

x * 5

14.

What does b-- do?

a)

Makes b negative

b)

Subtracts 1 from the value of b

c)

Nothing

d)

Subtracts 2 from the value of b

15.

What does

x %= 4;

do?

a)

divides x by 4

b)

sets x to the remainder when x is divided by 4

c)

gives an error

d)

sets x to 4%