Advertisements
Chapters
1.2: Elementary Concept of Objects and Classes
1.3: Values and Data Types
1.4: Operators in Java
1.5: Introduction to Java
1.5: Input in Java
1.6: Mathematical Library Methods
1.7: Conditional Statements in Java
1.8: Iterative Constructs in Java
1.9: Nested Loop
2: Library Classes
3: Arrays (Single Dimensional and Double Dimensional)
▶ 4: String Handling
5: User - Defined Methods
6: Class as the Basis of all Computation (Objects and Classes)
7: Constructors
8: Encapsulation and Inheritance
![Avichal solutions for Computer Applications [English] Class 10 ICSE chapter 4 - String Handling Avichal solutions for Computer Applications [English] Class 10 ICSE chapter 4 - String Handling - Shaalaa.com](/images/computer-applications-english-class-10-icse_6:1e1eb1b47d2b4696b609e5cd9260118f.jpg)
Advertisements
Solutions for Chapter 4: String Handling
Below listed, you can find solutions for Chapter 4 of CISCE Avichal for Computer Applications [English] Class 10 ICSE.
Avichal solutions for Computer Applications [English] Class 10 ICSE 4 String Handling Review Insight [Pages 284 - 285]
State the output of the following program segment.
String s = "Examination";
int n = s.length();
System.out.println(s.starts With(s.substring(5 ,n)));
System.out.println(s.charAt(2) == s.charAt(6));
State the data type and values of a and b after the following segment is executed.
String s1 = "Computer", s2 = "Applications";
a = (s1.compareTo (s2));
b = (s1.equals (s2));
What will be the output of the following code?
String s = "malayalam";
System.out.println(s.indexOf('m'));
System.out.println(s.lastlndexOf('m'));
Write a statement to show how finding the length of a character array chr[ ] differs from finding the length of String object str.
State the values stored in the variable str1 and str2.
String s1 = "good"; String s2 = "world matters";
String str1 = s2.substring(5).replace('t', 'n').
String str2 = s1.concat(strl1);
What is the data type that the following library function return?
isWhiteSpace(char ch)
What is the data type that the following library function return?
Math.random( )
State the output of the following program segment:
String str1 = "great"; String str2 = "minds";
System.out.println(str1.substring(0,2).concat(str2.substring(1)));
Systern.out.println(("WH" + (str1.substring(2).toUpperCase())));
What is the data type returned by the library function?
compareTo()
What is the data type returned by the library function?
equals()
State the value of characteristic and mantissa when the following code is executed:
String s = “4.3756”;
int n = s.indexOf(‘.’);
int characteristic=Integer.parseInt (s.substring (0,n));
int mantissa=Integer.valueOf(s.substring(n+1));
What will be the output when the following code segment is executed?
String s = “1001”;
int x = Integer. valueOf(s);
double y = Double.valueOf(s);
System.out.println(“x=”+x);
System.out.println(“y=”+y);
What is the value stored in variable res given below?
double res = Math.pow (“345”.indexOf(‘5’), 3);
State the output when the following program segment is executed:
String a = "Smartphone", b = "Graphic Art";
String h = a.substring(2, 5);
String k = b.substring(S).toUpperCase();
System.out.println(h);
System.out.println(k.equalsignoreCase(h));
Name a string function which removes the blank spaces provided in the prefix and suffix of a string.
State the difference between == operator and equals () method.
Give the output of the following string functions:
- "MISSISSIPPI".indexOf('S') + "MISSISSIPPI".lastIndexOf('I')
- "CABLE".compareTo("CADET")
Write the return type of the following library functions:
- isLetterOrDigit(char)
- replace(char, char)
You can use a variable to store a set of characters enclosed within opening and closing double quotes. A set of characters can also be stored in an object using a specific keyword. Such data are manipulated using different functions. One of them is used to extract a set of characters from such data whereas, other to join multiple set of characters to form a single set.
Based on the above discussion, answer the following questions:
- Which of the following variables is used to store a set of characters?
- Character variable
- Alphanumeric variable
- String variable
- Local variable
- Which of the following keywords is used to store a set of characters in an object?
- import
- oublic
- string
- new
- Which of the following functions is used to extract a set of characters?
- substring()
- charAt()
- indexOf()
- subIndex()
- Which of the following functions is used to join different set of characters into a single set?
- merge()
- concat()
- connect()
- join
Avichal solutions for Computer Applications [English] Class 10 ICSE 4 String Handling EXERCISES [Pages 286 - 293]
Multiple Choice Questions:
A string is:
A set of letters
A set of letters and digits
A set of letters, digits and special characters
All the above
A string internally creates:
An integer array
A numeric array
A character array
A double type array
If a string contains 12 characters, what will be the index of the last character?
12
11
10
0
What will be the value stored in the variable 'c' if the following statement is executed?
c = "COMPUTER".charAt("COMPUTER".indexOf('P'))
3
4
P
M
Which of the following functions is used to remove leading and trailing white spaces from the string?
trim()
trail()
truncate()
slice()
What will be the output of the following program snippet?
s1 = "COMPUTER"
s2 = "computer"
System.out.println(s1.equals(s2));
True
False
0
1
What will be the output of the following program snippet?
strl = "AMAN"8
str2 = "AMIT"
System.out.println(strl.compareTo(str2));
8
0
−8
2
Which of the following packages contain string functions?
java.awt
java.string
java.math
java.lang
Fill in the blanks:
______ method is used to join two strings.
The output of the following statement, when executed:
System.out.println("COMPUTER".charAt(4)); is ______.
The output of the statement, when executed:
System.out.println("Object Oriented".length()); is ______.
______ operator is used to concatenate two strings.
String declaration is terminated by the symbol ______.
Character literal is enclosed within ______.
The return type of the statement equals() is ______.
The output of "VIDYALAYA."substring(2,5) will result in ______.
Write down the syntax to perform the following task:
To check whether a character(chr) is in uppercase or not.
Write down the syntax to perform the following task:
To compare whether two Strings(str1, str2) are same or not.
Write down the syntax to perform the following task:
To extract the last character of a word(wd) stored in the variable chr.
Write down the syntax to perform the following task:
To return the first occurrence of 'a' in the word "applications".
Write down the syntax to perform the following task:
To replace the word "old" with the word "new" in a given String st = "old is always old".
Write down the syntax to perform the following task:
To check if the second character of a String(str) is in uppercase.
Predict the output of the following:
String str = "Computer Applications" + 1 + 0;
System.out.println("Understanding" + str);
Predict the output of the following:
String n1 = "46", n2 = "64";
int total = Integer.parselnt(n1) + Integer.parselnt(n2);
System.out.println("The sum of " + "46" + "and" + " 64" + "is" + total);
Predict the output of the following:
boolean p;
p = ("BLUEJ".length() > "bluej".length()) ? true: false;
Predict the output of the following:
String str = "Information Technology";
int p;
p = str.indexOf('n');
System.out.println(p);
Predict the output of the following:
String str1 = "Information Technology";
String str2 = "information technology";
boolean p = str1.equalsignoreCase(str2);
System.out.println("The result is" + p );
What do the following functions return?
String x = "Vision";
String y = "2020";
- System.out.println(x + y);
- System.out.printh1(x.length ());
- System.out.println(x.charAt(3));
- System.out.println(x.equals(y));
Predict the output of the following:
String S1 = "Computer World";
String S2 = "COMPUTER WORLD";
String S3 = "Computer world";
String S4 = "computer world";
System.out.println(S1 + "equals"+ S2 + " " + S1.equals(S2));
System.out.println(S1 + "equals"+ S3 + " " + S1.equals(S3));
System.out.println(S1 + "equals"+ S4 + " " + S1.equals(S4));
System.out.println(S1 + "equalslgnoreCase"+ S4 + " " + S1.equalslgnoreCase(S4));
If String x = "Computer";
String y = "Applications";
What do the following functions return?
- System.out. println(x.substring(1,5));
- System.out.println(x.indexOf(x.charAt(4)));
- System.out.println(y + x.substring(5));
- System.out.println(x.equals(y));
Give the output of the following:
String n = "Computer Knowledge";
String m = "Computer Applications”;
System.out.println(n.substring(0,8).concat(m.substring(9)));
System.out.println(n.endsWith("e"));
String x[] = {“SAMSUNG”, “NOKIA”, “SONY”, “MICROMAX”, “BLACKBERRY”};
Give the output of the following statements:
- System.out.println(x[1]);
- System.out.println(x[3].length());
Give the output of the following string functions:
- “ACHIEVEMENT”.replace(E’, ‘A’)
- “DEDICATE”.compareTo(“DEVOTE”)
Consider the following String array and give the output.
String arr[]= {"DELHI'', "CHENNAI", "MUMBAI", "LUCKNOW", "JAIPUR"};
System.out.println(arr[O].length() > arr[3].length());
System.out.print(arr[4].substring(0, 3));
Case-Study based question:
Your friend is trying to write a program to find and display the frequency of vowels in a string. Due to confusion in the syntax of some of the statements, he could not complete the program and has left some places blank marked with ?1?, ?2?, ?3? and ?4? to be filled with expression/function. The incomplete program is shown below:
import java.util.*;
class Vowels
{
public static void main(String args[])
{
Scanner ...?1?...=new Scanner(System.in);
String st;
int i, b, v = 0;
char chr;
System.out.println(“Enter a string”);
st=...........?2?............; // to input a string
st=..............?3?.............; // to convert the string into uppercase
b = st.length();
for (i = 0; i < b; i++)
{
chr= ......?4?......; // to extract a character
if (chr == "A" || chr == "E" || chr == "T" || chr == "0" || chr == "U")
v = v + 1;
}
System.out.printIn(“No. of Vowels = “ + v);
}
}
Based on the above discussion, answer the following questions:
- What expression / function will be filled in place of ?1?
- What expression /function will be filled in place of ?2?
- What expression /function will be filled in place of ?3?
- What expression /function will be filled in place of ?4?
Differentiate between equals() and ==
Differentiate between compareTo() and equals().
Differentiate between toLowerCase() and toUpperCase().
Differentiate between charAt() and substring().
Write short answers:
What is exception?
Name two exception handling blocks.
State the purpose and return data type of the following String function:
indexOf()
State the purpose and return data type of the following String function:
compareTo()
Write a statement to perform the following task on a string:
Extract the second last character of a word stored in the variable wd.
Write a statement to perform the following task on a string:
Check if the second character of a string str is in uppercase.
Write a statement to perform the following task on a string:
Find and display the position of the last space in a string s.
Write a statement to perform the following task on a string:
Convert a number stored in a string variable x to double data type.
How does endsWith() and startsWith() differ? Explain with an example.
Describe the purpose of the following function with its syntax:
toUpperCase()
Describe the purpose of the following function with its syntax:
trim()
Describe the purpose of the following function with its syntax:
toLowerCase()
Describe the purpose of the following function with its syntax:
length()
Describe the purpose of the following function with its syntax:
replace()
Describe the purpose of the following function with its syntax:
compareTo()
Describe the purpose of the following function with its syntax:
reverse()
Describe the purpose of the following function with its syntax:
indexOf()
Describe the purpose of the following function with its syntax:
startWith()
Describe the purpose of the following function with its syntax:
equalsignoreCase()
Unsolved Java Programming based on Strings:
Write a program to input a sentence. Find and display the following:
- Number of words present in the sentence
- Number of letters present in the sentence
Assume that the sentence neither includes any digit nor any special character.
Write a program in Java to accept a word / a String and display the new string after removing all the vowels present in it.
Sample Input: COMPUTER APPLICATIONS
Sample Output: CMPTR PPLCTNS
Write a program in Java to accept a name (Containing three words) and Display only the initials (i.e., first letter of each word).
Sample Input: LAL KRISHNA ADVANI
Sample output: L K A
Write a program in Java to accept a name containing three words and display the surname first, followed by the first and middle names.
Sample Input: MOHANDAS KARAMCHAND GANDHI
Sample output: GANDHI MOHANDAS KARAMCHAND
Write a program in Java to enter a String/Sentence and display the longest word and the length of the longest word present in the String.
Sample Input: "TATA FOOTBALL ACADEMY WILL PLAY AGAINST MOHAN BAGAN"
Sample output: The longest word: FOOTBALL: The length of the word: 8
Write a program in Java to accept a word and display the ASCII code of each character of the word.
Sample Input: BLUEJ
Sample output: ASCII of B = 66
ASCII of L = 75
ASCII of U = 84
ASCII of E = 69
ASCII of J = 73
Write a program in Java to accept a String in uppercase and replace all the vowels present in the String with Asterisk (*) sign.
Sample Input: "TATA STEEL IS IN JAMSHEDPUR"
Sample output: T*T* ST**L *S *N J*MSH*DP*R
Write a program in Java to enter a sentence. Frame a word by joining all the first characters of each word of the sentence. Display the word.
Sample Input: Vital Information Resource Under Seize
Sample Output: VIRUS
Write a program in Java to enter a sentence. Display the words which are only palindrome.
Sample Input: MOM AND DAD ARE NOT AT HOME
Sample Output: MOM
DAD
Write a program to accept a sentence. Display the sentence in reversing order of its word.
Sample Input: Computer is Fun
Sample Output: Fun is Computer
Write a program to input a sentence and display the word of the sentence that contains maximum number of vowels.
Sample Input: HAPPY NEW YEAR
Sample Output: The word with maximum number of vowels: YEAR
Consider the sentence as given below:
Blue bottle is in Blue bag lying on Blue carpet
Write a program to assign the given sentence to a string variable. Replace the word Blue with Red at all its occurrences. Display the new string as shown below:
Red bottle is in Red bag lying on Red carpet
Write a program to accept a word and convert it into lowercase, if it is in uppercase. Display the new word by replacing only the vowels with the letter following it.
Sample Input: computer
Sample Output: cpmpvtfr
Write a program to input a sentence. Create a new sentence by replacing each consonant with the previous letter. If the previous letter is a vowel then replace it with the next letter (i.e., if the letter is B then replace it with C as the previous letter of B is A). Other characters must remain same. Display the new sentence.
Sample Input: ICC WORLD CUP
Sample Output: IBB VOQKC BUQ
A 'Happy Word' is defined as:
Take a word and calculate the word's value based on position of the letters in English alphabet. On the basis of word's value, find the sum of the squares of its digits. Repeat the process with the resultant number until the number equals 1 (one). If the number ends with 1 then the word is called a 'Happy Word'. Write a program to input a word and check whether it a 'Happy Word' or not. The program displays a message accordingly.
Sample Input: VAT
Place value of V = 22, A = 1, T = 20
[Hint: A = 1, B = 2, ---------------------------, Z = 26]
Solution: 22120 ⇒ 22 + 22 + 12 + 22 + 02 = 13 ⇒ 12 + 32 = 10 ⇒ 12 + 02 = 1
Sample Output: A Happy Word
Write a program to input a sentence. Count and display the frequency of each letter of the sentence in alphabetical order.
Sample Input: COMPUTER APPLICATIONS
Sample Output:
Character | Frequency | Character | Frequency |
A | 2 | O | 2 |
C | 2 | P | 3 |
I | 1 | R | 1 |
L | 2 | S | 1 |
M | 1 | T | 2 |
N | 1 | U | 1 |
Write a program to accept a string. Convert the string into uppercase letters. Count and output the number of double letter sequences that exist in the string.
Sample Input: "SHE WAS FEEDING THE LITTLE RABBIT WITH AN APPLE"
Sample Output: 4
Special words are those words that start and end with the same letter.
Examples:
EXISTENCE
COMIC
WINDOW
Palindrome words are those words which read the same from left to right and vice versa
Examples:
MALAYALAM
MADAM
LEVEL
ROTATOR
CIVIC
All palindromes are special words, but all special words are not palindromes. Write a program to accept a word check and print Whether the word is a palindrome or only a special word.
Write a program to input a sentence. Convert the sentence into uppercase letters. Display the words along with frequency of the words which have at least a pair of consecutive letters.
Sample Input: MODEM IS AN ELECTRONIC DEVICE
Sample Output:
MODEM
DEVICE
Number of words containing consecutive letters: 2
Write a programme to accept a word (say, BLUEJ) and display the pattern:
- B L U E J
B L U E
B L U
B L
B - J
E E
U U U
L L L L
B B B B B - B L U E J
L U E J
U E J
E J
j
Write a program to display the pattern:
- A B C D E
B C D E
C D E
D E
E - A
B C
D E F
G H I J
K L M N O - A B C D E
A B C D A
A B C A B
A B A B C
A A B C D
Write a program to generate a triangle or an inverted triangle till n terms based upon the User's choice of the triangle to be displayed.
Example1: | Example2: |
Input: Type 1 for a triangle and Type 2 for an inverted triangle Enter your choice 1 Enter the number of terms 5 | Input: Type 1 for a triangle and Type 2 for an inverted triangle of alphabets Enter your choice 2 Enter the number of terms 5 |
Sample Output: * * * * * |
Sample Output: A B C D E |
Write a program to generate a triangle or an inverted choice. triangle based upon User's choice.
Example 1: | Example 2: |
Input: Type 1 for a triangle and Type 2 for an inverted triangle Enter your choice 1 Enter a word: BLUEJ | Input: Type 1 for a triangle and Type 2 for an inverted triangle Enter your choice 2 Enter a word: BLUEJ |
Sample Output: B |
Sample Output: B L U E J |
Using the switch statement, write a menu-driven program for the following:
(i) To print Floyd’s triangle [Given below]
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
(ii) To display the following pattern:
I
I C
I C S
I C S E
For an incorrect option, an appropriate error message should be displayed.
Write a program in Java to store 10 different country names and their capitals in two different Single Dimensional Arrays (SDA). Display the country names (that starts with a vowel) along with their capitals in the given format.
Country Names | Capital |
x x x x | x x x x |
x x x x | x x x x |
Write a program in Java to store 20 different names and telephone numbers of your friends in two different Single Dimensional Arrays (SDA). Now arrange all the names in alphabetical order and display all the names along with their respective telephone numbers use selection sort technique.
Write a program to accept 10 names in a Single Dimensional Array (SDA). Display the names whose first letter matches with the letter entered by the user.
Sample Input: Aman Shahi
Akash Gupta
Suman Mishra and so on --------
Sample Output: Enter a letter
A
Aman Shahi
Akash Gupta
--------------
Write a program to input twenty names in an array. Arrange these names in ascending order of letters, using the bubble sort technique.
Sample Input:
Rohit, Devesh, Indrani, Shivangi, Himanshu, Rishi, Piyush, Deepak, Abhishek, Kunal
Sample Output:
Abhishek, Deepak, Devesh, Himanshu, lndrani, Kunal, Piyush, Rishi, Rohit, Shivangi
Write a program in Java to input the names of 10 cities in a Single Dimensional Array. Display only those names which begin with a consonant but end with a vowel.
Sample Input: Kolkata, Delhi, Bengaluru, Jamshedpur, Bokaro, .............
Sample Output: Kolkata
Delhi
Bengaluru
Bokaro
.......................
.......................
Write a program in Java to store 10 words in a Single Dimensional Array. Display only those words which are Palindrome.
Sample Input: MADAM, TEACHER, SCHOOL, ABBA, ................
Sample Output: MADAM
ABBA
.................
.................
Write a program to accept the names of 10 cities in a single dimensional string array and their STD (Subscribers Trunk Dialling) codes in another single dimension integer array. Search for the name of a city input by the user in the list. If found, display "Search Successful" and print the name of the city along with its STD code, or else display the message "Search unsuccessful, no such city in the list".
Solutions for 4: String Handling
![Avichal solutions for Computer Applications [English] Class 10 ICSE chapter 4 - String Handling Avichal solutions for Computer Applications [English] Class 10 ICSE chapter 4 - String Handling - Shaalaa.com](/images/computer-applications-english-class-10-icse_6:1e1eb1b47d2b4696b609e5cd9260118f.jpg)
Avichal solutions for Computer Applications [English] Class 10 ICSE chapter 4 - String Handling
Shaalaa.com has the CISCE Mathematics Computer Applications [English] Class 10 ICSE CISCE solutions in a manner that help students grasp basic concepts better and faster. The detailed, step-by-step solutions will help you understand the concepts better and clarify any confusion. Avichal solutions for Mathematics Computer Applications [English] Class 10 ICSE CISCE 4 (String Handling) include all questions with answers and detailed explanations. This will clear students' doubts about questions and improve their application skills while preparing for board exams.
Further, we at Shaalaa.com provide such solutions so students can prepare for written exams. Avichal textbook solutions can be a core help for self-study and provide excellent self-help guidance for students.
Concepts covered in Computer Applications [English] Class 10 ICSE chapter 4 String Handling are Concept of String Class, String Functions, StringBuffer Functions.
Using Avichal Computer Applications [English] Class 10 ICSE solutions String Handling exercise by students is an easy way to prepare for the exams, as they involve solutions arranged chapter-wise and also page-wise. The questions involved in Avichal Solutions are essential questions that can be asked in the final exam. Maximum CISCE Computer Applications [English] Class 10 ICSE students prefer Avichal Textbook Solutions to score more in exams.
Get the free view of Chapter 4, String Handling Computer Applications [English] Class 10 ICSE additional questions for Mathematics Computer Applications [English] Class 10 ICSE CISCE, and you can use Shaalaa.com to keep it handy for your exam preparation.