ICSE Class 10 String Coding Questions
ICSE Class 10 String Coding Questions
Method overloading allows defining multiple methods with the same name but different parameter lists. In string manipulation, you can create overloaded methods like Joystring(String, char, char) to replace characters, Joystring(String) to find first and last space indices, and Joystring(String, String) to concatenate strings. This demonstrates versatility in handling different operations related to strings .
Store the city names in one array and their corresponding STD codes in another. To search, iterate over the city names array and compare each element with the user's input. If found, retrieve the STD code from the same index in the STD codes array and print alongside "Search Successful". If not found, print "Search Unsuccessful, No such city in the list" .
You can achieve this by splitting the sentence into words using space as a delimiter, then reversing the array of words, and finally joining them back into a sentence with spaces between each word. For example, reversing the words in 'He went to the market' yields 'market the to went He' .
You can write a loop that traverses the string, incrementing a counter each time the target character matches the current character in the string. For example, in the string 'success', the frequency of 's' is 3 .
Convert the string to lowercase and iterate through it, checking each character with a condition that it should be one of the vowels ('a', 'e', 'i', 'o', 'u'). Print each vowel that meets this condition. For instance, from the string 'computer', the vowels 'o u e' are extracted .
These methods provide essential operations for string manipulation. length() returns the total number of characters, enabling iterations; substring(start, end) extracts specific parts of a string; replace(old, new) finds all instances of a character and swaps them. Together, these methods facilitate complex operations on strings such as truncating, parsing, or reconstructing strings efficiently .
Use the Selection Sort algorithm to arrange names in alphabetical order. During each iteration, identify the minimum element among the unsorted names and swap it with the first unsorted element, adjusting both names and the corresponding phone numbers in parallel. Continue until the entire array is sorted .
To determine the number of digits, alphabets, and special characters in a given string, you can iterate through each character of the string and categorize it using condition checks: use Character.isDigit(char) to find digits, Character.isLetter(char) for alphabets, and treat others as special characters. For example, in the string 'KAPILDEV@83', there are 2 digits, 8 alphabets, and 1 special character .
A program should split the sentence into words and check each word for the presence of all vowels by converting it to lowercase and checking if 'a', 'e', 'i', 'o', 'u' are all present using conditionals or a set intersection method. For instance, in the sentence 'EDUCATION IS A MUST FOR THE DEVELOPMENT OF THE COUNTRY', the word 'EDUCATION' contains all five vowels .
To determine if two strings are anagrams, first remove spaces and punctuation, then convert both strings to lowercase, sort the characters of each string, and finally compare the sorted strings for equality. For instance, 'parliament' is an anagram of 'partial men' after ignoring spaces and sorting the letters .