Font size
WorksheetsJava Math Review
Total questions: 18
Worksheet time: 17mins
What command reads input from the keyboard?
Enter
Import
Scanner
import
What is the output?
4
1
num1
num1
4
5
4 5
What will the following code segment print?
System.out.println(4 / 5);
(a)
What will the following code segment print?
System.out.println(4 * 2.0);
(a)
What will the following code segment print?
System.out.println("b" + 2 * 2);
(a)
What will the following code segment print?
System.out.println(1 / 2.0);
(a)
What will be the value in variable x after this code segment is executed?
int x = 5.0 + 2;
7
7.0
There will be a runtime error
There will be a syntax error
5.02
What will be the value in variable x after this code segment is executed?
String x = "" + 4 + 2;
"6"
"6.0"
There will be a runtime error
There will be a syntax error
"42"
What will the following code segment print?
System.out.println(17 % 3);
(a)
What will the following code segment print?
System.out.println(6 % 9);
(a)
What will be the value in variable x after this code segment is executed?
double x = 5.0 + 2;
7
7.0
There will be a runtime error
There will be a syntax error
5.02
What will be the value in variable x after this code segment is executed?
int x = (int) 5.0 / 2;
2
2.5
There will be a runtime error
There will be a syntax error
3
int x = 15;
System.out.print(x);
0
1
2
3
System.out.print(4 % 3);
0.5
1
2
0
3
System.out.print(18 / 0);
0
1.8
ArithmeticExemption / Runtime Error
Syntax / Compiler Error
double y = 9 / 4;
System.out.print(y);
y
2.25
2
2.0
System.out.print(2 / 3);
1
0
2
6
