ICSE · Class 10 · Computer Applications

Class 10 String Handling Mock Test (ICSE)

5 practice questions from String Handling, in the style of your board paper, each with a worked answer and the marks for every step. Then take a full chapter test on paper, snap the pages and get every step marked.

Topics in String Handling

  • String class methods: length, charAt, indexOf, substring
  • compareTo, equals and equalsIgnoreCase
  • toUpperCase, toLowerCase, trim, replace
  • String concatenation
  • Programs on words, palindromes and character frequency

String Handling practice questions with answers

  1. Q1Multiple choice1 mark
    What is the output of the expression given below? " ICSE Java ".trim().length();
    1. (a)13
    2. (b)11
    3. (c)10
    4. (d)9
    Show answer and step marks
    1. Correct option: (d) 9+1
    Answer: (d)
  2. Q2Multiple choice1 mark
    What will be the output of the following statement? System.out.println(10 + 20 + "Java" + 10 + 20);
    1. (a)1020Java30
    2. (b)30Java1020
    3. (c)30Java30
    4. (d)1020Java1020
    Show answer and step marks
    1. Correct option: (b) 30Java1020+1
    Answer: (b)
  3. Q3Multiple choice1 mark
    What will be the output of the following statement? System.out.println("Computer".compareTo("Computers"));
    1. (a)8
    2. (b)-1
    3. (c)1
    4. (d)0
    Show answer and step marks
    1. Correct option: (b) -1+1
    Answer: (b)
  4. Q4Multiple choice1 mark
    Which of the following expressions correctly checks if a string variable str contains the character 'a' or 'A'?
    1. (a)str.contains('a')
    2. (b)str.search('a')
    3. (c)str.indexOf('a') ≥ 0 || str.indexOf('A') ≥ 0
    4. (d)str.indexOf("a", "A") ≠ -1
    Show answer and step marks
    1. Correct option: (c) str.indexOf('a') ≥ 0 || str.indexOf('A') ≥ 0+1
    Answer: (c)
  5. Q5Long answer4 marks
    Write a program in Java to accept a sentence from the user. Convert the sentence to uppercase. Count and display the frequency of each vowel (AA, EE, II, OO, UU) present in the sentence using string handling methods.
    Show answer and step marks
    1. Importing Scanner class, creating the class and main method, and accepting the sentence.+1
    2. Converting the string to uppercase and setting up variables/counters for each vowel.+1
    3. Using a loop with charAt() and conditional statements to correctly count the frequency of each vowel.+1
    4. Displaying the frequency of each vowel with proper output messages.+1
    Answer: import java.util.Scanner; class Vowels { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String s = sc.nextLine().toUpperCase(); int a = 0, e = 0, i = 0, o = 0, u = 0; for (int k = 0; k < s.length(); k++) { char c = s.charAt(k); if (c == 'A') a++; else if (c == 'E') e++; else if (c == 'I') i++; else if (c == 'O') o++; else if (c == 'U') u++; } System.out.println("A = " + a + ", E = " + e + ", I = " + i + ", O = " + o + ", U = " + u); } }

Take a full String Handling test

PrepitUp writes a fresh paper on this chapter at the length you pick. Write it on paper with a timer, photograph the pages, and see the marks for every step and what to practise next.

  • 15 min10 marks
  • 30 min20 marks
  • 1.5 hr40 marks
  • 3 hr80 marks
See a sample marked answer sheet

Get your String Handling answers marked

Sign in, pick this chapter and a length, write the test on paper and get every step marked.

Sign in to take this test

More Class 10 Computer Applications mock tests