Professional Documents
Culture Documents
1. s.lastIndexOf(‘p’);
a. 2
b. 8
c. 9
2. s.substring(0,4).charAt(2);
a. h
b. i
c. p
3. s.substring(3,5).concat(s.substring(0,2));
a. pohi
b. pochip
c. pohic
4. s.compareTo(“hippo”);
a. -1
b. 6
c. -6
5. s.indexOf(s.charAt(8));
a. 2
b. 3
c. 8
1. Character.isUpperCase(s.charAt(3))
a. true
b. false
c. M
3. s.equals(“committee”);
a. true
b. false
c. -32
4. s.indexOf(‘m’) + s.lastIndexOf(‘m’)
a. 5
SHAILESH MANJREKAR – 98194 98104
b. 7
c. mM
5. s = “ “ + s + “ “;
System.out.println(s.length() );
s = s.trim();
System.out.println(s.length());
a. 11
9
b. 11
11
c. 9 11
2. The function equalsIgnoreCase() returns true even if the cases are different
a. true
b. false
c. none
4. The output of
s=” computer applications “
System.out.println(s.trim());
a. ”computer applications “
b. ”computerapplications”
c. ” computer applications “
1. s.substring(0,4).toUpperCase()
a. ELE
b. ELEM
c. LEME
2. s.substring(3,5).concat(s.substring(5))
a. ments
b.mennts
c. ment
3. s.equalsIgnoreCase(“Element”)
a. true
b. false
c. 0
4. s.startsWith(‘e’)
a. true
b. false
c. StringIndexOutOfBoundsException
5. s.substring(2,5).endsWith(‘e’)
a. true
b. false
c. none
1. Write the memory in bytes that the following strings will occupy
a. “Dorem@\non”
b. “1234@onetwothreefour”
c. “old\t\”man\”on the road’s”
1. 2. 3.
for (i=0; i<S.length(); i++) for (int i=2; i<s.indexOf(‘r’); i++) int count = 2;
{ System.out.println(S1.charAt(i- while ( count < s.length()-2 )
char ch = S.charAt(i); 1)); {
if ( System.out.println(s.charAt(count+1);
Character.isDigit(ch)==false) count++;
System.out.println(ch); }
}
Q5. Programs
1. Write a program which inputs a String and counts the number of vowels present in the string.
2. Write a program which inputs a String and check if the String is palindrome. A palindrome String is the one which
when reversed gives the same word again, eg : MOM.
3. Write a program to input 2 Strings. Covert the strings to uppercase and join them to create a new String. Also
compare the length of the two strings and print the string with a smaller length. Print EQUAL if the length of the 2
strings is equal.