Java String Methods

Java String Methods

9th - 12th Grade

7 Qs

quiz-placeholder

Similar activities

Python Review

Python Review

11th Grade

11 Qs

Evaluasi Bab 9

Evaluasi Bab 9

10th Grade

10 Qs

Exploring Python: Input and Output Essentials

Exploring Python: Input and Output Essentials

9th Grade - University

10 Qs

String

String

10th - 12th Grade

10 Qs

Algorithms / Methods

Algorithms / Methods

9th Grade

8 Qs

CPro-Unit6-String

CPro-Unit6-String

10th Grade - University

6 Qs

String Methods (easy)

String Methods (easy)

11th Grade - University

9 Qs

Java String Methods

Java String Methods

Assessment

Quiz

Computers

9th - 12th Grade

Hard

Created by

Michael Toepper

Used 85+ times

FREE Resource

7 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Media Image

What will myString.length() return?

27

28

26

29

Answer explanation

myString is 28 characters long

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Media Image

What will myString.indexOf("Sci") return?

8

9

10

-1

Answer explanation

remember the first character of a String is at index 0

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Media Image

What will myString.indexOf("x") return?

15

16

17

-1

Answer explanation

indexOf method returns -1 when the actual parameter is not found in the String object referenced before the dot "."

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Media Image

What will myString.substring(12) return?

e

ence is awesome!

This is invalid

cience is awesome!

Answer explanation

when only one actual parameter called with the substring method, the substring returned starts at the index given through the end of the String

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Media Image

What will myString.substring(10,15) return?

Scien

c

cienc

cien

Answer explanation

the index of the last character in the substring returned is one character before the second integer given in the method call

[(from, to) -> to index-1]

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Media Image

What will myString.substring( myString.length()-1) return?

-1

e

This is invalid

!

Answer explanation

length() is always one more than than the last index, so length()-1 is always gives the last character from a String

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Media Image

What will myString.substring( myString.length()) return?

!

e!

This is invalid

Computer Science is awesome!

Answer explanation

length() will always return an integer one greater than the index of the last character in a String, so using length() for an index will give a value outside the largest index of a String