No student devices needed. Know more
12 questions
int len = "jump it!".length();
What is the value of len?
8
7
9
6
This code does not compile.
int x = "quarantine".indexOf("a");
What is the value of x?
4
3
2
This code does not compile.
StringIndexOutOfBoundsException
String s = "whatever".substring(1,4);
What is the value of s?
"hate"
"hat"
"whate"
"what"
StringIndexOutOfBoundsException
String s1 = "hello";
String s2 = new String("hello");
if (s1 == s2) System.out.print("Hey");
else System.out.print("Yo");
What is the output?
Hey
Yo
There is no output.
This code will not compile.
int p = "Go Paw Patrol!".indexOf("p");
What is the value of p?
0
4
3
-1
This code will not compile.
String s = "cool cat".substring(6);
What is the value of s?
"cat"
"at"
"cool c"
This code does not compile.
StringIndexOutOfBoundsException
int x = "Mary".compareTo("Molly");
if (x>=0) System.out.print("Yes");
else System.out.print("No");
What is the output?
Yes
No
There is no output.
This code will not compile.
String s1 = "goat";
String s2 = s1.substring(0,s1.length());
boolean z = s1.equals(s2);
What is the value of z?
true
false
This code will not compile.
StringIndexOutOfBoundsException
String s = "good job".substring(3, 9);
What is the value of s?
"d job"
"od job"
"d jo"
"od jo"
StringIndexOutOfBoundsException
int x = "bob".compareTo("Bob");
if (x>=0) System.out.print("Good");
else System.out.print("Bad");
What is the output?
Good
Bad
There is no output.
This code will not compile.
Which code segment should go in the blank so that count is equal to the number of times "whoa" occurs in str?
str.length() -2
str.length() -4
str.length() - 3
str.length() - 1
str.length()
Which code segment should go in the blank so that count is equal to the number of times "whoa" occurs in str?
pos>0
pos>=0
pos<0
pos<=0
pos==0
Explore all questions with a free account