wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Java Math Review

Total questions: 18

Worksheet time: 17mins

Name
Class
Date
1.

What command reads input from the keyboard?

a)

Enter

b)

Import

c)

Scanner

d)

import

2.

What is the output?

a)

4

1

b)

num1

num1

c)

4

5

d)

4 5

3.

What would command do you use to read in the number?

a)

bob.nextint( );

b)

bob.nextDouble( );

c)
d)

bob.nextInt( );

4.

What will the following code segment print?

System.out.println(4 / 5);

(a)  

5.

What will the following code segment print?

System.out.println(4 * 2.0);

(a)  

6.

What will the following code segment print?

System.out.println("b" + 2 * 2);

(a)  

7.

What will the following code segment print?

System.out.println(1 / 2.0);

(a)  

8.

What will be the value in variable x after this code segment is executed?

int x = 5.0 + 2;

a)

7

b)

7.0

c)

There will be a runtime error

d)

There will be a syntax error

e)

5.02

9.

What will be the value in variable x after this code segment is executed?

String x = "" + 4 + 2;

a)

"6"

b)

"6.0"

c)

There will be a runtime error

d)

There will be a syntax error

e)

"42"

10.

What will the following code segment print?

System.out.println(17 % 3);

(a)  

11.

What will the following code segment print?

System.out.println(6 % 9);

(a)  

12.

What will be the value in variable x after this code segment is executed?

double x = 5.0 + 2;

a)

7

b)

7.0

c)

There will be a runtime error

d)

There will be a syntax error

e)

5.02

13.

What will be the value in variable x after this code segment is executed?

int x = (int) 5.0 / 2;

a)

2

b)

2.5

c)

There will be a runtime error

d)

There will be a syntax error

e)

3

14.

int x = 15;

x = x % 5;
System.out.print(x);

a)

0

b)

1

c)

2

d)

3

15.

System.out.print(4 % 3);

a)

0.5

b)

1

c)

2

d)

0

e)

3

16.

System.out.print(18 / 0);

a)

0

b)

1.8

c)

ArithmeticExemption / Runtime Error

d)

Syntax / Compiler Error

17.

double y = 9 / 4;

System.out.print(y);

a)

y

b)

2.25

c)

2

d)

2.0

18.

System.out.print(2 / 3);

a)

1

b)

0

c)

2

d)

6