(vi)
(a) Name one String method which results in a positive integer only.
(b) Name one String method which results in a character.

Single Choice
Views 42

Answer:

Solution:

(a) A String method that results in a positive integer only:
length() → This method returns the length of the string as a positive integer.
Example:


String str = "Hello";
System.out.println(str.length()); // Output: 5

(b) A String method that results in a character:
charAt(int index) → This method returns the character at the specified index.
Example:


String str = "Hello";
System.out.println(str.charAt(1)); // Output: 'e'

Related Articles:

This section is dedicated exclusively to Questions & Answers. For an in-depth exploration of ICSE Computer Applications Class 10 – Previous Year Question Papers & Solutions, click the links and dive deeper into this subject.

Join Our telegram group to ask Questions

Click below button to join our groups.