ICSE Class 10 Computer Applications Question 18 of 30

Solved 2025 Specimen Paper ICSE Class 10 Computer Applications — Question 18

Back to all questions
18
Question

Question 1(xviii)

The statement used to find the total number of Strings present in the string array String s[] is:

  1. s.length
  2. s.length()
  3. length(s)
  4. len(s)
Answer

s.length

Reason — In Java, arrays have a property called length, which gives the total number of elements in the array. This applies to any type of array, including arrays of Strings.

For a string array String s[], the correct way to get the number of elements is:

s.length

Analysing other options:

  1. s.length():

    • Incorrect. The length() method is used for String objects to get the number of characters in a String, not for arrays.
  2. length(s):

    • Incorrect. This is not a valid syntax in Java.
  3. len(s):

    • Incorrect. Java does not have a function called len() for arrays or strings.