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

String Methods Quiz

star
star
star
star
star
Posljednje ažuriranje about 2 years ago
21
4
4
4
4
4
4
4
4
4
4
20
Pitanje 1
1.

Consider the following code segment.

String s = "dogfood";

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

Pitanje 2
2.

Consider the following code segment.

String s = "dogfood";

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

Pitanje 3
3.

Consider the following code segment.

String s = "dogfood";

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

Pitanje 4
4.

Consider the following code segment.

String s = "dogfood";

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

Pitanje 5
5.

Consider the following code segment.

String s = "dogfood";

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

Pitanje 6
6.

Consider the following code segment.

String s = "dogfood";

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

Pitanje 7
7.

Consider the following code segment.

String s = "dogfood";

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

Pitanje 8
8.

Consider the following code segment.

String s = "dogfood";

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

Pitanje 9
9.

What is output by the code below?

String s = "abac-adae-bfbg-bhbi";

int index = s.indexOf("ae");

System.out.println( index );

Pitanje 10
10.

What is output by the code below?

String s = "abac-adae-bfbg-bhbi";

int index = s.indexOf("-b");

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

DIRECTIONS : Fill in each blank with the correct answer/output. Assume each statement happens in order and that one statement may affect the next statement.

String one = "apcomputersciencerocks";

String two = "098765210AB#";

String three = "02 13 998 45 0";

4
Pitanje 11
11.

System.out.print( one.length());

4
4
4
4
4
4
4
4
4
Pitanje 21
21.

DIRECTIONS : Write a return method named wow that return the last ½ of a string plus the word "FUN". The call wow("compze") returns "pzeFUN"

public static String wow( String s ){

///your code goes here///

}

Pitanje 12
12.

System.out.print( two.length());

Pitanje 13
13.

System.out.print( three.length());

Pitanje 14
14.

System.out.print( one.substring(0,4) );

Pitanje 15
15.

System.out.print( one.substring(5) );

Pitanje 16
16.

System.out.print( one.substring(9) );

Pitanje 17
17.

System.out.print( one.indexOf( "c" ) );

Pitanje 18
18.

System.out.print( one.indexOf( "sci" ) );

Pitanje 19
19.

System.out.print( one.indexOf( "code" ) );

Pitanje 20
20.

System.out.print( one.lastIndexOf( "c" ) );