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

ICSE Class 10 Computer Applications PYQ · 2025 Specimen · Section A

1(xviii)1 Mark · 2025 · Section A · 2025 Specimen

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

Show SolutionHide Solution↓

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.
← Previous questionNext question →

Browse the free Computer Applications sample bank