Java String Methods
Quiz
•
Computers
•
9th - 12th Grade
•
Practice Problem
•
Hard
Michael Toepper
Used 87+ times
FREE Resource
Enhance your content in a minute
7 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will myString.length() return?
27
28
26
29
Answer explanation
myString is 28 characters long
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
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
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
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
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
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
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
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?
Similar Resources on Wayground
10 questions
ICT Java programming workshop
Quiz
•
9th Grade
10 questions
CALL: Causative Verb
Quiz
•
10th - 11th Grade
12 questions
website design elements
Quiz
•
12th Grade
10 questions
TIN 11- KIỂU XÂU
Quiz
•
11th Grade
10 questions
C# lesson10
Quiz
•
1st - 10th Grade
10 questions
مراجعة الوحدة 3 ( البرمجة بواسطة المايكروبت )
Quiz
•
12th Grade
10 questions
Recursion Practice, Recursion Practice, Recursion Practice...
Quiz
•
10th Grade - University
10 questions
Year 8 - Progress Check 1 (Python Turtle Shapes)
Quiz
•
8th - 9th Grade
Popular Resources on Wayground
15 questions
Fractions on a Number Line
Quiz
•
3rd Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
22 questions
fractions
Quiz
•
3rd Grade
20 questions
Main Idea and Details
Quiz
•
5th Grade
20 questions
Context Clues
Quiz
•
6th Grade
15 questions
Equivalent Fractions
Quiz
•
4th Grade
20 questions
Figurative Language Review
Quiz
•
6th Grade
