Log in
Sign up for FREE
arrow_back
Library
Strings Test
By Mickey Arnold
star
star
star
star
star
Share
share
Last updated about 2 years ago
34 questions
Add this activity
2.5
2.5
2.5
2.5
2.5
2.5
2.5
2.5
2.5
2.5
2.5
2.5
2.5
2.5
2.5
2.5
2.5
2.5
2.5
2.5
2.5
2.5
2.5
2.5
2.5
2.5
2.5
2.5
2.5
2.5
2.5
2.5
2.5
17.5
Question 1
1.
Question 2
2.
Question 3
3.
Question 4
4.
Question 5
5.
Question 6
6.
Question 7
7.
Question 8
8.
Question 9
9.
Question 10
10.
Question 11
11.
Question 12
12.
Question 13
13.
Question 14
14.
Question 15
15.
Question 16
16.
Question 17
17.
Question 18
18.
Question 19
19.
Question 20
20.
Question 21
21.
Question 22
22.
Question 23
23.
Question 24
24.
Question 25
25.
Question 26
26.
Question 27
27.
Question 28
28.
Question 29
29.
Question 30
30.
Question 31
31.
Question 32
32.
Question 33
33.
Question 34
34.
DIRECTIONS :
Complete the method below.
You will be writing only the go method.
The go method should:
Two words are sent in to the go method as word1 and letter1
You will
RETURN
an int containing the SUM of both locations for letter1 in word1
The answer will be printed in main so you do not need any System.out.println
Show your work is there if you need it.
public static int go (String word1, char letter1){
//Your code will go here
}
visibility
View drawing
What is output by the code below?
String s = "apluscompsci";
System.out.println( s.substring(4,5) );
a
u
p
l
s
What is output by the code below?
String s = "apluscompsci";
System.out.println( s.substring( s.length()-1 ) );
s
i
ci
a
p
What is output by the code below?
String s = "apluscompsci";
System.out.println( s.charAt( s.length()-3 ) );
s
i
a
p
c
What is output by the code below?
String s = "apluscompsci";
System.out.println( s.charAt(0) );
a
c
p
i
s
What is output by the code below?
String s = "apluscompsci";
System.out.println( s.charAt(5) );
c
s
p
i
u
What is output by the code below?
String s = "apluscompsci";
System.out.println( s.indexOf( "s" ) );
3
6
5
4
9
What is output by the code below?
String s = "apluscompsci";
System.out.println( s.indexOf( "apluscomp" ) );
0
1
2
3
4
What is output by the code below?
String s = "ishouldofstudied";
System.out.println( s.length() );
13
12
15
16
14
What is output by the code below?
String s = "apluscompsci";
System.out.println( s.substring( 6 ) );
aplus
compsci
sci
o
ompsci
What is output by the code below?
String s = "apluscompsci";
System.out.println( s.indexOf( "b" ) );
0
1
2
3
-1
What is output by the code below?
String s = "apluscompsci";
int x = s.indexOf( "c" );
System.out.println( s.substring( x ) );
compsci
sci
comp
aplus
pluscompsci
What is output by the code below?
int x = "alligator".length() - "crocodile".length();
System.out.println( x );
1
-2
2
-1
0
What is output by the code below?
int x = "crocodile".length() - "croc".length();
System.out.println( x );
-5
1
-1
0
5
What is output by the code below?
String s = "apluscompsci";
System.out.println( s.substring(0,2) );
a
p
pl
ap
us
What is output by the code below?
String s = "apluscompsci";
int x = 3;
System.out.println( s.substring(x,x+1) );
s
u
p
0
m
What is output by the code below?
String s = "dog";
String r = "dog ";
System.out.println( s.equals( r ) );
1
0
false
true
null
What is output by the code below?
String s = "dog ";
String r = new String("dog");
System.out.println( s.equals( r ) );
true
1
null
false
0
What is output by the code below?
String s = "dog";
String r = new String("dog");
System.out.println( s != r );
0
false
1
true
null
What is output by the code below?
String s = "dog";
String r = "dog";
r = s;
s = null;
System.out.println( r );
true
null
dog
s
false
What is output by the code below?
String s = "dog";
String r = s;
s = null;
System.out.println( s );
null
s
true
false
dog
What is output by the code below?
String s = "Big dog";
String r = "A dog";
System.out.println( s.compareTo(r) );
1
true
null
0
false
What is output by the code below?
String s = "dog";
String r = "cog";
System.out.println( r.compareTo(s) );
-1
3
null
0
1
What is output by the code below?
String s = "dodge";
String r = "cloths";
System.
out
.println( s.compareTo(r) );
1
0
null
3
-1
What is output by the code below?
String s = "bob";
String r = "bod";
System.out.println( s.compareTo(r) );
1
-2
-5
6
-6
What is output by the code below?
String s = 12;
int x = Integer.parseInt( s );
System.out.println( x + 3 );
There is no output due to an error.
0
x3
12
15
What is output by the code below?
String s = "12.7";
Double x = Double.
parseDouble
( s );
System.
out
.println( x + 3 );
15.7
There is no output due to an error.
0
x3
12.7
What is output by the code below?
String s = "12.7";
double x = Double.parseDouble( s );
System.out.println( x + 3 );
12.7
15.7
0
x3
There is no output due to an error.
What is output by the code below?
String s = "12";
int x = Integer.parseInt( s );
System.out.println( s + x + 3 );
There is no output due to an error.
12x3
1215
12123
27
What is output by the code below?
System.out.println( "12" + 9 + 3 );
24
null
There is no output due to an error.
1293
1212
What is returned by the call
myst("aplus","aplus")
?
public boolean myst(String a, String b)
{
return a.equals( b );
}
1
false
true
null
0
What is returned by the call
myst("aplus","aplus")
?
public boolean myst(String a, String b)
{
return a == b;
}
1
null
false
0
true
What is returned by the call
myst("ana","banana")
?
public boolean myst(String a, String b)
{
return b.lastIndexOf(a)!=b.indexOf(a);
}
false
0
1
null
true
What is the purpose of myst?
public boolean myst(String a, String b)
{
return b.lastIndexOf(a)!=b.indexOf(a);
}
to determine if a occurs exactly once in b
to determine if there are at least two occurrences of a in b.
none of the above
to determine if a is in b
to determine if there are less than two occurrences of a in b