KnowledgeBoat Logo
|

Computer Applications

Which of the following String methods has integer argument?

(i) length
(ii) substring
(iii) indexOf
(iv) charAt

  1. Only (ii)
  2. (i) and (iv)
  3. (ii) and (iv)
  4. (iii) and (iii)

Java String Handling

3 Likes

Answer

(ii) and (iv)

Reason — The substring(int beginIndex) and charAt(int index) methods both take an integer argument to specify a position within the string. The substring method returns a part of the string starting from the given index, while charAt returns the character at the specified index.

Answered By

1 Like


Related Questions