Java String Methods

Quiz
•
Computers
•
9th - 12th Grade
•
Hard
Michael Toepper
Used 85+ times
FREE Resource
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
Similar Resources on Wayground
10 questions
L.8. STRINGS AND STRING MANIPULATION - 2

Quiz
•
12th Grade
10 questions
Python Arithmetic Operators

Quiz
•
8th - 9th Grade
10 questions
VB Using Expressions and Operators

Quiz
•
10th Grade
11 questions
Java Substring 10.18

Quiz
•
10th Grade
10 questions
Quiz 15 - Array Basics

Quiz
•
11th Grade
10 questions
String Handling Quiz

Quiz
•
11th Grade
10 questions
STRING HANDLING

Quiz
•
10th Grade
10 questions
Java Strings

Quiz
•
1st Grade - Professio...
Popular Resources on Wayground
10 questions
Video Games

Quiz
•
6th - 12th Grade
10 questions
Lab Safety Procedures and Guidelines

Interactive video
•
6th - 10th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
10 questions
UPDATED FOREST Kindness 9-22

Lesson
•
9th - 12th Grade
22 questions
Adding Integers

Quiz
•
6th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
20 questions
US Constitution Quiz

Quiz
•
11th Grade
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade
Discover more resources for Computers
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade
20 questions
Analog vs Digital

Quiz
•
9th - 12th Grade
10 questions
CTEA Computer Vocab Terms #1

Quiz
•
12th Grade
10 questions
Exploring Cybersecurity Techniques and Threats

Interactive video
•
6th - 10th Grade
10 questions
Understanding the Internet and Data Transmission

Interactive video
•
7th - 12th Grade