wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Java Character and String class methods

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

What method would you use to see if two String's are equal?

a)

==

b)

.equals

c)

.equal

d)

.similar

2.

What method would you use to see if two String's are in alphabetical order?

a)

.compareTo

b)

.alpha

c)

.orderBy

3.

What method would you use to check if two String's are the same excluding upper and lower case?

a)

.equalsIgnoreCase

b)

.theSameNoCase

c)

.isItEqual

d)

.equalsNoCase

4.

What method do you use to find how many characters are in a String?

a)

.length

b)

.numChars

c)

.noNo

d)

.lenCh

5.

To find where in a String a certain character can be found, use this method:

a)

.indexOf

b)

.whereIsIt

c)

.charAt

d)

.substring

6.

"Anne".compareTo("Bill") > 0

TRUE or FALSE?

a)

TRUE

b)

FALSE

7.

"Mandela".length()

a)

7

b)

6

c)

8

d)

5

8.

"Jack".equals("jack")

a)

TRUE

b)

FALSE

9.

"Jack".equalsIgnoreCase("jack")

a)

TRUE

b)

FALSE

10.

"Brutus".indexOf('t')

a)

2

b)

3

c)

4

d)

1