Preskoči na glavni sadržaj
Prijava
Sign up for FREE
arrow_back
Biblioteka

Strings Test

star
star
star
star
star
Posljednje ažuriranje about 2 years ago
34 questions
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
Pitanje 1
1.

What is output by the code below?

String s = "apluscompsci";

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

Pitanje 2
2.

What is output by the code below?

String s = "apluscompsci";

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

Pitanje 3
3.

What is output by the code below?

String s = "apluscompsci";

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

Pitanje 4
4.

What is output by the code below?

String s = "apluscompsci";

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

Pitanje 5
5.

What is output by the code below?

String s = "apluscompsci";

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

Pitanje 6
6.

What is output by the code below?

String s = "apluscompsci";

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

Pitanje 7
7.

What is output by the code below?

String s = "apluscompsci";

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

Pitanje 8
8.

What is output by the code below?

String s = "ishouldofstudied";

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

Pitanje 9
9.

What is output by the code below?

String s = "apluscompsci";

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

Pitanje 10
10.

What is output by the code below?

String s = "apluscompsci";

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

Pitanje 11
11.

What is output by the code below?

String s = "apluscompsci";

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

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

Pitanje 12
12.

What is output by the code below?

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

System.out.println( x );

Pitanje 13
13.

What is output by the code below?

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

System.out.println( x );

Pitanje 14
14.

What is output by the code below?

String s = "apluscompsci";

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

Pitanje 15
15.

What is output by the code below?

String s = "apluscompsci";

int x = 3;

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

Pitanje 16
16.

What is output by the code below?

String s = "dog";

String r = "dog ";

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

Pitanje 17
17.

What is output by the code below?

String s = "dog ";

String r = new String("dog");

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

Pitanje 18
18.

What is output by the code below?

String s = "dog";

String r = new String("dog");

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

Pitanje 19
19.

What is output by the code below?

String s = "dog";

String r = "dog";

r = s;

s = null;

System.out.println( r );

Pitanje 20
20.

What is output by the code below?

String s = "dog";

String r = s;

s = null;

System.out.println( s );

Pitanje 21
21.

What is output by the code below?

String s = "Big dog";

String r = "A dog";

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

Pitanje 22
22.

What is output by the code below?

String s = "dog";

String r = "cog";

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

Pitanje 23
23.

What is output by the code below?

String s = "dodge";

String r = "cloths";

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

Pitanje 24
24.

What is output by the code below?

String s = "bob";

String r = "bod";

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

Pitanje 25
25.

What is output by the code below?

String s = 12;

int x = Integer.parseInt( s );

System.out.println( x + 3 );

Pitanje 26
26.

What is output by the code below?

String s = "12.7";

Double x = Double.parseDouble( s );

System.out.println( x + 3 );

Pitanje 27
27.

What is output by the code below?

String s = "12.7";

double x = Double.parseDouble( s );

System.out.println( x + 3 );

Pitanje 28
28.

What is output by the code below?

String s = "12";

int x = Integer.parseInt( s );

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

Pitanje 29
29.

What is output by the code below?

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

Pitanje 30
30.

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

public boolean myst(String a, String b)

{

return a.equals( b );

}

Pitanje 31
31.

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

public boolean myst(String a, String b)

{

return a == b;

}

Pitanje 32
32.

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

public boolean myst(String a, String b)

{

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

}

Pitanje 33
33.

What is the purpose of myst?

public boolean myst(String a, String b)

{

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

}

Pitanje 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

}