RANI LAXMIBAI PUBLIC SCHOOL, JHANSI
WORKSHEET – 2 (SEMESTER – 2 EXAMINATION 2021-22)
CLASS – X (TOPIC – STRING HANDLING)
SUBJECT – COMPUTER APPLICATIONS
1. Write a program to accept a sentence and word from the user. The program should count
and print the number of times the word appears in the sentence either as a separate word
or as a part of another word.
Example: INPUT – “the digit and the number is checked with another”
WORD TO CHECK – “the”
OUTPUT – frequency of the word the is = 3
2. Write a program to input a name. Print the given name and also the initials of that name
except the last name.
INPUT – "Mohan Das Karam Chand Gandhi“
OUTPUT – M.D.K.C. Gandhi
3. Write a program to accept a string. Convert the string to Uppercase. Count and output
the number of double letter sequences that exist in the string.
INPUT – “SHE WAS FEEDING THE LITTLE RABBIT WITH AN
APPLE”
OUTPUT – 4
4. Write a program to accept a word. Check and print whether the word is a Palindrome
word or Special word.
SPECIAL WORD – Those words which starts and ends with the same letter.Ex:
Existence, Comic.
PALINDROME WORD – Those words which read the same from left to right and vice
– versa. Ex: Malayalam, Level, Civic.
5. Write a program to input a string. Display the original string and the new string after
reversing each word at its own place.
INPUT – “This Is A Zoo”
OUTPUT – sihT sI A ooZ
6. Write a program to input a string and convert it into uppercase and print the frequency
of each character.
INPUT – Computer Hardware
OUTPUT –
Characters Frequency
A 2
C 1
D 1
E 2
H 1
M 1
O 1
P 1
R 3
T 1
U 1
W 1
7. WAP to input a sentence and print the total number of words, total number of spaces
and total number of alphabets.
8. WAP to input a name . convert its each letter to its opposite case. Print the original and
modified name along with suitable message.
Example: INPUT James Bond
OUTPUT Original name : James Bond
Modified name : jAMES bOND
9. State the values stored in the variables str1 and str2
String s1 = “good”; String s2 = “world matters”;
String str1 = s2.substring(7).replace(‘t’ , ‘d’ );
String str2 = s1.concat(str1);
10.WAP to input a Word and convert i tinto uppercase and print the Word by removing the
consecutive repeated characters from the Word and print the new Word generated.
Ex:INPUT:- “JAAAAAVVVVVVVAAAAA” OUTPUT:- JAVA
11.WAP to accept a Word and convert i tinto lowercase letters, and display the new Word
by replacing only the vowels with the characters following it. Ex: INPUT:
“program” OUTPUT: prpgrbm
12.WAP to input a sentence and display the number of vowels in each Word. Also derive
the Acronym of the sentence.
EX: INPUT: “UNFOLDING THE GOLDEN RATIO”
OUTPUT: UNFOLDING – 3, THE – 1, GOLDEN – 2, RATIO – 3, Acronym – UTGR
13.Write output if s1=”MAHATMA”, s2=”GANDHI”
System.out.println(s1.length()+s2.length());
System.out.println(s1.charAt(3)+s2.charAt(5));
14.Write a statement to check if the second character of String str is in uppercase
15.Write the output: System.out.println(“MOUNTAIN”.charAt(4));
16.Write the output: System.out.println(“INTERMISSION ”.substring(5));
17.Write the output: System.out.println(“UNIVERSAL”.indexOf(‘v’));
18.Write the output: System.out.println(“Java”.compareTo(“Java”));
19.Predict the Output: [4]
String st1 = “India”;
String st2 = “Wins”;
String st3 = “World Cup Cricket 2020”;
(i) System.out.println(st1+st2+st3);
(ii) System.out.println(st3.length( ) – st2.length( ));
(iii) System.ouit.println(str.substring(0,10));
(iv) System.out.println(str3.charAt( 0 )+str2.charAt(6) + st3.charAt(10));
20.Write a program to input a sentence. Find and display the following:
(i) Number of words present in the sentence
(ii) Number of letters present in the sentence
Assume that the sentence has neither include any digit nor a special character.
PARIVESH AGARWAL
(HOD – Comp Sc.)