Twa kɔ nsɛm atitiriw so
Log in
Sign up for FREE
arrow_back
Laabri

Strings Test

star
star
star
star
star
Last updated about 2 years ago
34 Nsɛmmisa
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
Asemmisa {{asɛmmisaAhyɛnsode}}
1.

What is output by the code below?

String s = "apluscompsci";

System.out.println( s.substring(4,5) );

Asemmisa {{asɛmmisaAhyɛnsode}}
2.

What is output by the code below?

String s = "apluscompsci";

System.out.println( s.substring( s.length()-1 ) );

Asemmisa {{asɛmmisaAhyɛnsode}}
3.

What is output by the code below?

String s = "apluscompsci";

System.out.println( s.charAt( s.length()-3 ) );

Asemmisa {{asɛmmisaAhyɛnsode}}
4.

What is output by the code below?

String s = "apluscompsci";

System.out.println( s.charAt(0) );

Asemmisa {{asɛmmisaAhyɛnsode}}
5.

What is output by the code below?

String s = "apluscompsci";

System.out.println( s.charAt(5) );

Asemmisa {{asɛmmisaAhyɛnsode}}
6.

What is output by the code below?

String s = "apluscompsci";

System.out.println( s.indexOf( "s" ) );

Asemmisa {{asɛmmisaAhyɛnsode}}
7.

What is output by the code below?

String s = "apluscompsci";

System.out.println( s.indexOf( "apluscomp" ) );

Asemmisa {{asɛmmisaAhyɛnsode}}
8.

What is output by the code below?

String s = "ishouldofstudied";

System.out.println( s.length() );

Asemmisa {{asɛmmisaAhyɛnsode}}
9.

What is output by the code below?

String s = "apluscompsci";

System.out.println( s.substring( 6 ) );

Asemmisa {{asɛmmisaAhyɛnsode}}
10.

What is output by the code below?

String s = "apluscompsci";

System.out.println( s.indexOf( "b" ) );

Asemmisa {{asɛmmisaAhyɛnsode}}
11.

What is output by the code below?

String s = "apluscompsci";

int x = s.indexOf( "c" );

System.out.println( s.substring( x ) );

Asemmisa {{asɛmmisaAhyɛnsode}}
12.

What is output by the code below?

int x = "alligator".length() - "crocodile".length();

System.out.println( x );

Asemmisa {{asɛmmisaAhyɛnsode}}
13.

What is output by the code below?

int x = "crocodile".length() - "croc".length();

System.out.println( x );

Asemmisa {{asɛmmisaAhyɛnsode}}
14.

What is output by the code below?

String s = "apluscompsci";

System.out.println( s.substring(0,2) );

Asemmisa {{asɛmmisaAhyɛnsode}}
15.

What is output by the code below?

String s = "apluscompsci";

int x = 3;

System.out.println( s.substring(x,x+1) );

Asemmisa {{asɛmmisaAhyɛnsode}}
16.

What is output by the code below?

String s = "dog";

String r = "dog ";

System.out.println( s.equals( r ) );

Asemmisa {{asɛmmisaAhyɛnsode}}
17.

What is output by the code below?

String s = "dog ";

String r = new String("dog");

System.out.println( s.equals( r ) );

Asemmisa {{asɛmmisaAhyɛnsode}}
18.

What is output by the code below?

String s = "dog";

String r = new String("dog");

System.out.println( s != r );

Asemmisa {{asɛmmisaAhyɛnsode}}
19.

What is output by the code below?

String s = "dog";

String r = "dog";

r = s;

s = null;

System.out.println( r );

Asemmisa {{asɛmmisaAhyɛnsode}}
20.

What is output by the code below?

String s = "dog";

String r = s;

s = null;

System.out.println( s );

Asemmisa {{asɛmmisaAhyɛnsode}}
21.

What is output by the code below?

String s = "Big dog";

String r = "A dog";

System.out.println( s.compareTo(r) );

Asemmisa {{asɛmmisaAhyɛnsode}}
22.

What is output by the code below?

String s = "dog";

String r = "cog";

System.out.println( r.compareTo(s) );

Asemmisa {{asɛmmisaAhyɛnsode}}
23.

What is output by the code below?

String s = "dodge";

String r = "cloths";

System.out.println( s.compareTo(r) );

Asemmisa {{asɛmmisaAhyɛnsode}}
24.

What is output by the code below?

String s = "bob";

String r = "bod";

System.out.println( s.compareTo(r) );

Asemmisa {{asɛmmisaAhyɛnsode}}
25.

What is output by the code below?

String s = 12;

int x = Integer.parseInt( s );

System.out.println( x + 3 );

Asemmisa {{asɛmmisaAhyɛnsode}}
26.

What is output by the code below?

String s = "12.7";

Double x = Double.parseDouble( s );

System.out.println( x + 3 );

Asemmisa {{asɛmmisaAhyɛnsode}}
27.

What is output by the code below?

String s = "12.7";

double x = Double.parseDouble( s );

System.out.println( x + 3 );

Asemmisa {{asɛmmisaAhyɛnsode}}
28.

What is output by the code below?

String s = "12";

int x = Integer.parseInt( s );

System.out.println( s + x + 3 );

Asemmisa {{asɛmmisaAhyɛnsode}}
29.

What is output by the code below?

System.out.println( "12" + 9 + 3 );

Asemmisa {{asɛmmisaAhyɛnsode}}
30.

What is returned by the call myst("aplus","aplus")?

public boolean myst(String a, String b)

{

return a.equals( b );

}

Asemmisa {{asɛmmisaAhyɛnsode}}
31.

What is returned by the call myst("aplus","aplus")?

public boolean myst(String a, String b)

{

return a == b;

}

Asemmisa {{asɛmmisaAhyɛnsode}}
32.

What is returned by the call myst("ana","banana")?

public boolean myst(String a, String b)

{

return b.lastIndexOf(a)!=b.indexOf(a);

}

Asemmisa {{asɛmmisaAhyɛnsode}}
33.

What is the purpose of myst?

public boolean myst(String a, String b)

{

return b.lastIndexOf(a)!=b.indexOf(a);

}

Asemmisa {{asɛmmisaAhyɛnsode}}
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

}