Page 322 - ComputerScience_Class_11
P. 322
The output should be as follows:
welcome to computer world
Index of o from index 10 : 12
Length : 25
3. Write a program using StringBuffer to store the string "Technology and Innovation Drive Growth".
The program should:
• Delete the word "and " using the delete() method.
• Convert the modified string into uppercase letters (by first converting it into String).
• Display the final result.
The output should be as follows:
TECHNOLOGY INNOVATION DRIVE GROWTH
G. Find the output of the following programs:
1. class StringExample
{
public static void main(String args[])
{
String str = "Education";
System.out.println("Length : " + str.length());
System.out.println("Index of 'a' : " + str.indexOf('a'));
System.out.println(str.toUpperCase());
}
}
2. class StringExample
{
public static void main(String args[])
{
String s = "Character123";
System.out.println(s.toLowerCase());
System.out.println("Index of 'r' from index 4 : " + s.indexOf('r', 4));
System.out.println("Length : " + s.length());
}
}
3. class StringBufferTest
{
public static void main(String args[])
{
StringBuffer sb = new StringBuffer("Modern Technology");
sb.delete(6, 17);
System.out.println(sb);
}
}
320 Touchpad Computer Science (Ver. 3.0)-XI

