Explain method String substring(int beginIndex, int endIndex) and what it returns?
Question 42
42.
Explain method int indexOf(String str) and what it returns?
Question 43
43.
Explain method int length() and what purpose it serves?
Question 44
44.
How many indexOf methods does the String have? Define the term overloading. Is the String indexOf method overloaded?
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 = "sambenwilearethebest";
String two = "09876543210";
String three = "02 13 97 68 45 0";
Question 1
1.
System.out.print( one.length());
Question 2
2.
System.out.print( two.length());
Question 3
3.
System.out.print( three.length());
Question 4
4.
System.out.print( one.charAt( 2 ) );
Question 5
5.
System.out.print( one.charAt( 5 ));
Question 6
6.
System.out.print(one.charAt(one.length()-1));
Question 7
7.
System.out.print( one.charAt( 6 ) );
Question 8
8.
System.out.print( one.substring(0,4) );
Question 9
9.
System.out.print( one.substring(5) );
Question 10
10.
System.out.print( one.substring(9) );
Question 11
11.
System.out.print( one.substring(2,7));
Question 12
12.
System.out.print( one.indexOf("abc") );
Question 13
13.
System.out.print( one.indexOf("e") );
Question 14
14.
System.out.print( one.indexOf("hij") );
Question 15
15.
System.out.print( two.indexOf("54"));
Question 16
16.
System.out.print( two.indexOf("24"));
Question 17
17.
System.out.print( one.indexOf( 'w' ));
Question 18
18.
System.out.print( two.indexOf( 'b' ));
Question 19
19.
System.out.print( two.indexOf( 's' ));
Question 20
20.
System.out.print( three.indexOf("45"));
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.