
Worksheet – 1
Sub: Computer Application
Std: 10[ICSE]
I. Write Java statements for the following
1. To display the size of the last word in the given string
2. To check which of the 2 strings is longest.
3. To find a new string after joining the first 3 characters and last characters of the
string.
4. To convert the full string to capital letters.
5. To replace all the appearances of “Kumar” to “Sharma”.
II. Write output for the following
1. String s=”APARNA”;
System.out.println(s.replace(s.charAt(0). ‘O’));
System.out.println(s.substring(0,2)+s.substring(s.length()-2));
2. String s=”10 ICSE”, s1=”20-20 Match”;
System.out.println(s.substring(0,2)+s1.subtring(3,5));
System.out.println(Integer.parseInt(s.substring(0,2))+Integer.parseInt(s1.subtring(3,5)));
System.out.println(s.charAt(4)+13);
III. Write Java Programs
1. Write a program to find and display the potential of the string.
The potential of a word is found by adding the encrypted value of the alphabets.
Example: KITE
Potential = 11 + 9 + 20 + 5 = 45
2. Write a program to input the string, first convert it to uppercase and then encrypt it as
follows.
AC, BD,….. XZ, YA, ZB
02, 13, … 79, 80, 91
Ex: Input: 15 AUGUST 1947
Output: 37 CWIWUV 3169