ICSE Class 10 Computer Applications
Question 18 of 30
Solved 2025 Specimen Paper ICSE Class 10 Computer Applications — Question 18
Back to all questionss.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.lengthAnalysing other options:
s.length():- Incorrect. The
length()method is used for String objects to get the number of characters in a String, not for arrays.
- Incorrect. The
length(s):- Incorrect. This is not a valid syntax in Java.
len(s):- Incorrect. Java does not have a function called
len()for arrays or strings.
- Incorrect. Java does not have a function called