wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Java Math and String Libraries

Total questions: 14

Worksheet time: 8mins

Name
Class
Date
1.
What is the value of num?
double num = Math.pow(2, 5);
a)
10.0
b)
7.0
c)
32.0
d)
25.0
2.
What is the value of num?
double num = Math.sqrt(49);
a)
7
b)
7.0
3.
What is the value of num?
double num = Math.floor(123.75);
a)
123.0
b)
124.0
4.
What is the value of num?
double num = Math.ceil(45.17);
a)
45.0
b)
46.0
5.
What is the value of num?
double num = Math.abs(-1.28);
a)
1.28
b)
-1.28
c)
1.3
d)
1.2
6.
What is the value of num?
double num = Math.max(100, 200);
a)
100.0
b)
200.0
c)
300.0
d)
150.0
7.
What is the value of num?
double num = Math.min(100,200);
a)
100.0
b)
200.0
c)
150.0
d)
300.0
8.
String word = "A few good men";
What is word.length()?
a)
14
b)
15
c)
13
9.
String word = "A few good men";
What is word.charAt(7) ?
a)
o
b)
g
c)
7
d)
good men
10.
String word = "A few good men";
What is word.startsWith("A few") ?
a)
true
b)
false
11.
String word = "A few good men";
What is word.endsWith("man") ?
a)
true
b)
false
12.
String word = "A few good men";
What is word.indexOf(“f”)?
a)
2
b)
0
c)
1
d)
-1
13.
String word = "A few good men";
What is word.indexOf(“bad”)?
a)
0
b)
-1
c)
3
14.
String word = "A few good men";
What is word.substring(3, 7) ?
a)
ew g
b)
ew go
c)
few
d)
few[space]