wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Split String Method + java-Visuals

Total questions: 78

Worksheet time: 26mins

Name
Class
Date
1.
What is the output of the split() method when the limit is set to 0?
a)
The string is split into substrings, with trailing empty strings removed.
b)
The string is split into substrings, including trailing empty strings.
c)
The string is not split at all.
d)
The string is split into substrings, with the delimiter removed.
2.
What is the delimiter used to split the string in the image?
a)
Comma (,)
b)
Period (.)
c)
Space ( )
d)
Tab (\t)
3.
What is the first step in splitting a string by comma in Java?
a)
Create a string variable with comma separated string.
b)
Call the split() method on the string object.
c)
Convert the array to ArrayList of String.
d)
Print the array of strings.
4.
What is the value of the variable arr[3] in the image?
a)
This
b)
is
c)
a
d)
split
5.
What is the output of the code in the image?
a)
JAVA, PHP, WORDPRESS, MYSQL, DATABASE
b)
JAVA
c)
PHP
d)
WORDPRESS
6.
What is the output of the code in the image?
a)
String[3]{"Hello", "World", "2019"}
b)
String[2]{"Hello", "World 2019"}
c)
String[5]{"Hello", "World", "20", "1", "9"}
d)
String[4]{"Hello", "World", "201", "9"}
7.
What is the value of the variable subtitleArray at the end of the code in the image?
a)
String[23]{"w", "w", "w₁", "f", "a", "c", "e", "b", "o", "o", "k", ".", "f", "a", "c", "e", "b", "o", "o", "k", ".", "c", "o", "m", ".", "h", "e", "1", "1", "c"}
b)
String[22]{"w", "w", "w₁", "f", "a", "c", "e", "b", "o", "o", "k", ".", "f", "a", "c", "e", "b", "o", "o", "k", ".", "c", "o", "m"}
c)
String[21]{"w", "w", "w₁", "f", "a", "c", "e", "b", "o", "o", "k", ".", "f", "a", "c", "e", "b", "o", "o", "k"}
d)
String[20]{"w", "w", "w₁", "f", "a", "c", "e", "b", "o", "o", "k", ".", "f", "a", "c", "e", "b", "o", "o"}
8.
What is the length of the array s2 in the image?
a)
17
b)
18
c)
19
d)
20
9.
What is the value of the variable name at the end of the code in the image?
a)
Andrew Carnegie
b)
John Doe
c)
Jane Doe
d)
Unknown
10.
What is the value of the variable length at the end of the code in the image?
a)
10
b)
11
c)
12
d)
13
11.
What is the output of the code in the image?
a)
Hello, World!
b)
World!
c)
Hello
d)
None of the above
12.
What is the delimiter used to split the string in the image?
a)
Space ( )
b)
Comma (,)
c)
Dash (-)
d)
Tab (\t)
13.
What is the output of the code in the image?
a)
Array Element = We
b)
Array Element = are
c)
Array Element = abc
d)
Array Element = working in abe company since abe years
14.
What is the value of the variable size at the end of the code in the image?
a)
2
b)
3
c)
4
d)
5
15.
What is the output of the code in the image?
a)
String[5]{"This", "is", "a", "split", "example"}
b)
String[4]{"This", "is", "a", "split"}
c)
String[3]{"This", "is", "a"}
d)
String[2]{"This", "is"}
16.
What is the value of the variable s2 at the end of the code in the image?
a)
String[2]{"JAVA", "PHP"}
b)
String[3]{"JAVA", "PHP", "WORDPRESS"}
c)
String[4]{"JAVA", "PHP", "WORDPRESS", "MYSQL"}
d)
String[5]{"JAVA", "PHP", "WORDPRESS", "MYSQL", "DATABASE"}
17.
What is the value of the variable subStr at the end of the code in the image?
a)
"Java"
b)
"Java 17"
c)
"17"
d)
""
18.
What is the output of the code in the image?
a)
Hello World!
b)
Hello!
c)
World!
d)
Nothing
19.
What is the output of the code in the image?
a)
Hello, World!
b)
World!
c)
Hello
d)
None of the above
20.
What is the value of the variable length at the end of the code in the image?
a)
5
b)
6
c)
7
d)
8
21.
What is the delimiter used to split the string in the image?
a)
Space ( )
b)
Comma (,)
c)
Dash (-)
d)
Tab (\t)
22.
What is the value of the variable s2 at the end of the code in the image?
a)
String[2]{"JAVA", "PHP"}
b)
String[3]{"JAVA", "PHP", "WORDPRESS"}
c)
String[4]{"JAVA", "PHP", "WORDPRESS", "MYSQL"}
d)
String[5]{"JAVA", "PHP", "WORDPRESS", "MYSQL", "DATABASE"}
23.
What is the purpose of the w shorthand metacharacter in the image?
a)
To match a word character.
b)
To match a whitespace character.
c)
To match a digit character.
d)
To match any character.
24.
What is the output of the code in the image?
a)
Java
b)
Java 17
c)
17
d)
None of the above
25.
What is the output of the code in the image?
a)
Java
b)
PHP
c)
WORDPRESS
d)
DATABASE
26.
What is the output of the code in the image?
a)
Java 17
b)
17
c)
14
d)
None of the above
27.
What is the name of the Java logo mascot?
a)
Duke
b)
Green
c)
Coffee
d)
Sun
28.
Which of the following is the correct syntax for the Java split() method?
a)
String[] split(String regex)
b)
String[] split(String regex, int limit)
c)
String[] split(int limit)
d)
String[] split()
29.
What is the output of the following Java code?
a)
4
b)
5
c)
6
d)
7
30.
What is the name of the method in Java that is used to split a string?
a)
split()
b)
splitString()
c)
stringSplit()
d)
substring()
31.
What is being cut in the image?
a)
A piece of paper
b)
A string
c)
A rope
d)
A sign
32.
What is the name of the C# operator that is used to return one of two values, depending on whether a condition is true or false?
a)
Conditional operator
b)
Ternary operator
c)
If statement
d)
Else statement
33.
What is the delimiter used to split the string in the image?
a)
Comma (,)
b)
Space ( )
c)
Hash (#)
d)
Pipe (|)
34.
What is the output of the following Java code?
a)
[I, am, a, java, developer]
b)
[I am a java developer]
c)
[I, am, java, developer]
d)
[java developer]
35.
What is the name of the person who is not in the image?
a)
Suresh
b)
Rohini
c)
Trishika
d)
Tutlane
36.
Which method is used to split the string in the image?
a)
split()
b)
splitString()
c)
stringSplit()
d)
substring()
37.
What is the delimiter used to split the string in the image?
a)
Space ( )
b)
Comma (,)
c)
Hash (#)
d)
Pipe (|)
38.
What is the delimiter used to split the string in the image?
a)
Comma (,)
b)
Period (.)
c)
Space ( )
d)
Tab (\t)
39.
Which of the following is the return type of the split() method?
a)
String
b)
Boolean
c)
Integer
d)
Array of Strings
40.
What is the value of the variable name after the split() method is called?
a)
John Gilbert
b)
43
c)
UK
d)
[John Gilbert, 43, UK]
41.
What is the delimiter used to split the string in the image?
a)
Comma (,)
b)
Pipe (|)
c)
Space ( )
d)
Newline (\n)
42.
What is the name of the Java icon in the image?
a)
Coffee cup
b)
Java logo
c)
Java coffee cup
d)
Java programming language
43.
What is the output of the code in the image?
a)
1
b)
2
c)
3
d)
1 2 3 4 5 6
44.
What is the value of the variable phoneString after the split() method is called?
a)
91-77536222
b)
[91, -, 7753, 6222]
c)
9177536222
d)
[917753, 6222]
45.
What is the length of the longest substring that starts with the letter "g"?
a)
1
b)
2
c)
3
d)
4
46.
What is the name of the exception that is thrown in the image?
a)
PatternSyntaxException
b)
RuntimeException
c)
IOException
d)
ParseException
47.
What is the value of the variable data after the split() method is called?
a)
1648
b)
1658
c)
166
d)
[1648, 1658, 166]
48.
What is the return type of the split() method?
a)
String
b)
Boolean
c)
Integer
d)
Array of Strings
49.
What is the delimiter used to split the string in the image?
a)
Comma (,)
b)
Period (.)
c)
Space ( )
d)
Tab (\t)
50.
What is the delimiter used to split the string in the image?
a)
Comma (,)
b)
Period (.)
c)
Space ( )
d)
Tab (\t)
51.
What is the output of the code in the image?
a)
public class JavaSplitString {
b)
public static void main(String[] args) {
c)
String s = "This is a string with spaces";
d)
String[] words = s.split(" ");
52.
What is the inclusive/exclusive behavior of the startindex and endIndex parameters in the substring() method?
a)
Startindex is inclusive, endIndex is exclusive. [Image shows this behavior]
b)
Startindex is exclusive, endIndex is inclusive.
c)
Both startindex and endIndex are inclusive.
d)
Both startindex and endIndex are exclusive.
53.
Which of the following methods is used to parse a comma-separated string in Java?
a)
String.split() [Image shows this method being used]
b)
StringTokenizer.split()
c)
Arrays.split()
d)
String.join()
54.
What is the output of the following code?
a)
Study [Image shows this output]
b)
Studyopedia
c)
provides
d)
free learning content!
55.
What is the output of the following code?
a)
enter the dragon [Image shows this output]
b)
enterthedragon
c)
enter the dragonechy com
d)
None of the above
56.
What is the name of the company that developed the Java programming language?
a)
Oracle
b)
Microsoft
c)
Google
d)
IBM
57.
What is the name of the method that is used to split a string in Java?
a)
split()
b)
substring()
c)
replace()
d)
trim()
58.
1
a)
Template literals
b)
Backticks
c)
Escape characters
d)
Concatenation
59.
What is the regular expression that is being used to split the string in the code snippet?
a)
\\r\\n
b)
\\n
c)
\\r
d)
\\s
60.
What is the name of the coffee shop that is featured in the logo for strings in Java?
a)
Starbucks
b)
Coffee Bean & Tea Leaf
c)
Peet's Coffee
d)
Dutch Bros. Coffee
61.
What is the length of the string in the image?
a)
4
b)
5
c)
6
d)
7
62.
What is the name of the icon in the image?
a)
Gears
b)
Star
c)
Plus
d)
Oval
63.
What is the regular expression that can be used to split a string by new line in Java?
a)
\\n
b)
\\r
c)
\\r\\n
d)
\\s
64.
What is the Java code to split a string by space?
a)
String[] splitString = myString.split(" ");
b)
String[] splitString = myString.split("\\s");
c)
String[] splitString = myString.split("\n");
d)
String[] splitString = myString.split("\r");
65.
What is the output of the Python code in the image?
a)
['Learn', 'Python', 'at', 'Tutorial', 'Gateway', 'For', 'Free']
b)
['Learn', 'Python', 'at', 'TutorialGateway.org']
c)
['Apple', 'Orange', 'Banana', 'Kiwi', 'Cherry', 'Mango', 'Berry']
d)
`['']
66.
What is the name of the variable that is used to store the output of the split() method?
a)
splitString
b)
text
c)
myString
d)
result
67.
What is the value of the variable count after the code has been executed?
a)
1
b)
2
c)
3
d)
4
68.
What is the output of the program in the flowchart?
a)
5
b)
10
c)
15
d)
20
69.
What is the output of the Java code in the image?
a)
['Hello', 'World!']
b)
['Hello']
c)
['World!']
d)
[]
70.
Which of the following is the output of the Python code in the image?
a)
['Split', 'String', 'in', 'Python']
b)
['Split', 'String']
c)
['String', 'in', 'Python']
d)
['Python']
71.
What is the length of the string in the image?
a)
9
b)
10
c)
11
d)
12
72.
What is the output of the Python code in the image?
a)
enter-the-dragon
b)
enter the dragon
c)
enter the dragon'
d)
None
73.
What is the output of the Python code in the image?
a)
['ab', '12', 'cd']
b)
['ab', '#', '12', '#', 'cd']
c)
['ab12cd']
d)
['ab#12cd']
74.
What is the output of the Python code in the image?
a)
['This', 'is', 'a', 'string', 'with', 'spaces']
b)
['This is a string', 'with spaces']
c)
['This', 'a string with spaces']
d)
['This', 'is', 'a', 'string', 'with', 'space']
75.
What is the first element of the array returned by the str_split() function when it is passed the string "What do you want to learn?"?
a)
What
b)
do
c)
you
d)
want
76.
What is the package name of the String class in Java?
a)
java.lang
b)
java.util
c)
java.io
d)
java.math
77.
What is the code that is used to split the string "item1, item2, item3" into an array of strings in C#?
a)
string[] wordArray = line0fText.Split(",");
b)
string[] wordArray = line0fText.Split(" ");
c)
string[] wordArray = line0fText.Split(".");
d)
string[] wordArray = line0fText.Split("-");
78.
What is the name of the author of the book "Core Java Volume I - Fundamentals, Tenth Edition"?
a)
Cay S. Horstmann
b)
John Quelch
c)
Katherine E. Jocz
d)
Cory Doctorow