Strings Test
star
star
star
star
star
Last updated over 1 year ago
34 questions
2.5
What is output by the code below?
String s = "apluscompsci";System.out.println( s.substring(4,5) );
What is output by the code below?
String s = "apluscompsci";
System.out.println( s.substring(4,5) );
2.5
What is output by the code below?
String s = "apluscompsci";System.out.println( s.substring( s.length()-1 ) );
What is output by the code below?
String s = "apluscompsci";
System.out.println( s.substring( s.length()-1 ) );
2.5
What is output by the code below?
String s = "apluscompsci";System.out.println( s.charAt( s.length()-3 ) );
What is output by the code below?
String s = "apluscompsci";
System.out.println( s.charAt( s.length()-3 ) );
2.5
What is output by the code below?
String s = "apluscompsci";System.out.println( s.charAt(0) );
What is output by the code below?
String s = "apluscompsci";
System.out.println( s.charAt(0) );
2.5
What is output by the code below?
String s = "apluscompsci";System.out.println( s.charAt(5) );
What is output by the code below?
String s = "apluscompsci";
System.out.println( s.charAt(5) );
2.5
What is output by the code below?
String s = "apluscompsci";System.out.println( s.indexOf( "s" ) );
What is output by the code below?
String s = "apluscompsci";
System.out.println( s.indexOf( "s" ) );
2.5
What is output by the code below?
String s = "apluscompsci";System.out.println( s.indexOf( "apluscomp" ) );
What is output by the code below?
String s = "apluscompsci";
System.out.println( s.indexOf( "apluscomp" ) );
2.5
What is output by the code below?
String s = "ishouldofstudied";System.out.println( s.length() );
What is output by the code below?
String s = "ishouldofstudied";
System.out.println( s.length() );
2.5
What is output by the code below?
String s = "apluscompsci";System.out.println( s.substring( 6 ) );
What is output by the code below?
String s = "apluscompsci";
System.out.println( s.substring( 6 ) );
2.5
What is output by the code below?
String s = "apluscompsci";System.out.println( s.indexOf( "b" ) );
What is output by the code below?
String s = "apluscompsci";
System.out.println( s.indexOf( "b" ) );
2.5
What is output by the code below?
String s = "apluscompsci";int x = s.indexOf( "c" );System.out.println( s.substring( x ) );
What is output by the code below?
String s = "apluscompsci";
int x = s.indexOf( "c" );
System.out.println( s.substring( x ) );
2.5
What is output by the code below?
int x = "alligator".length() - "crocodile".length();System.out.println( x );
What is output by the code below?
int x = "alligator".length() - "crocodile".length();
System.out.println( x );
2.5
What is output by the code below?
int x = "crocodile".length() - "croc".length();System.out.println( x );
What is output by the code below?
int x = "crocodile".length() - "croc".length();
System.out.println( x );
2.5
What is output by the code below?
String s = "apluscompsci";System.out.println( s.substring(0,2) );
What is output by the code below?
String s = "apluscompsci";
System.out.println( s.substring(0,2) );
2.5
What is output by the code below?
String s = "apluscompsci";int x = 3;System.out.println( s.substring(x,x+1) );
What is output by the code below?
String s = "apluscompsci";
int x = 3;
System.out.println( s.substring(x,x+1) );
2.5
What is output by the code below?
String s = "dog";String r = "dog ";System.out.println( s.equals( r ) );
What is output by the code below?
String s = "dog";
String r = "dog ";
System.out.println( s.equals( r ) );
2.5
What is output by the code below?
String s = "dog ";String r = new String("dog");System.out.println( s.equals( r ) );
What is output by the code below?
String s = "dog ";
String r = new String("dog");
System.out.println( s.equals( r ) );
2.5
What is output by the code below?
String s = "dog";String r = new String("dog");System.out.println( s != r );
What is output by the code below?
String s = "dog";
String r = new String("dog");
System.out.println( s != r );
2.5
What is output by the code below?
String s = "dog";String r = "dog";r = s;s = null;System.out.println( r );
What is output by the code below?
String s = "dog";
String r = "dog";
r = s;
s = null;
System.out.println( r );
2.5
What is output by the code below?
String s = "dog";String r = s;s = null;System.out.println( s );
What is output by the code below?
String s = "dog";
String r = s;
s = null;
System.out.println( s );
2.5
What is output by the code below?
String s = "Big dog";String r = "A dog";System.out.println( s.compareTo(r) );
What is output by the code below?
String s = "Big dog";
String r = "A dog";
System.out.println( s.compareTo(r) );
2.5
What is output by the code below?
String s = "dog";String r = "cog";System.out.println( r.compareTo(s) );
What is output by the code below?
String s = "dog";
String r = "cog";
System.out.println( r.compareTo(s) );
2.5
What is output by the code below?
String s = "dodge";String r = "cloths";System.out.println( s.compareTo(r) );
What is output by the code below?
String s = "dodge";
String r = "cloths";
System.out.println( s.compareTo(r) );
2.5
What is output by the code below?
String s = "bob";String r = "bod";System.out.println( s.compareTo(r) );
What is output by the code below?
String s = "bob";
String r = "bod";
System.out.println( s.compareTo(r) );
2.5
What is output by the code below?
String s = 12;int x = Integer.parseInt( s );System.out.println( x + 3 );
What is output by the code below?
String s = 12;
int x = Integer.parseInt( s );
System.out.println( x + 3 );
2.5
What is output by the code below?
String s = "12.7";Double x = Double.parseDouble( s );System.out.println( x + 3 );
What is output by the code below?
String s = "12.7";
Double x = Double.parseDouble( s );
System.out.println( x + 3 );
2.5
What is output by the code below?
String s = "12.7";double x = Double.parseDouble( s );System.out.println( x + 3 );
What is output by the code below?
String s = "12.7";
double x = Double.parseDouble( s );
System.out.println( x + 3 );
2.5
What is output by the code below?
String s = "12";int x = Integer.parseInt( s );System.out.println( s + x + 3 );
What is output by the code below?
String s = "12";
int x = Integer.parseInt( s );
System.out.println( s + x + 3 );
2.5
What is output by the code below?
System.out.println( "12" + 9 + 3 );
What is output by the code below?
System.out.println( "12" + 9 + 3 );
2.5
What is returned by the call myst("aplus","aplus")?public boolean myst(String a, String b){ return a.equals( b );}
What is returned by the call myst("aplus","aplus")?
public boolean myst(String a, String b)
{
return a.equals( b );
}
2.5
What is returned by the call myst("aplus","aplus")?public boolean myst(String a, String b){ return a == b;}
What is returned by the call myst("aplus","aplus")?
public boolean myst(String a, String b)
{
return a == b;
}
2.5
What is returned by the call myst("ana","banana")?public boolean myst(String a, String b){ return b.lastIndexOf(a)!=b.indexOf(a);}
What is returned by the call myst("ana","banana")?
public boolean myst(String a, String b)
{
return b.lastIndexOf(a)!=b.indexOf(a);
}
2.5
What is the purpose of myst?public boolean myst(String a, String b){ return b.lastIndexOf(a)!=b.indexOf(a);}
What is the purpose of myst?
public boolean myst(String a, String b)
{
return b.lastIndexOf(a)!=b.indexOf(a);
}
17.5
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 letter1You will RETURN an int containing the SUM of both locations for letter1 in word1The answer will be printed in main so you do not need any System.out.printlnShow your work is there if you need it.
public static int go (String word1, char letter1){ //Your code will go here}
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
}