Ask Question
31 October, 23:34

What method of the String object searches the string for an occurence of the specified search string?

the charAt () method

the search () method

the indexOf () method

the substring () method

+2
Answers (1)
  1. 1 November, 03:13
    0
    the indexOf () method

    Explanation:

    The indexOf () method in java returns the first occurrence of the of the string or a character specified in it. It can be used to search both a character or a string.

    for example:-

    import java. util.*;

    import java. lang.*;

    import java. io.*;

    class indexOf

    {

    public static void main (String[] args)

    {

    String s="IamNumber4";

    int l=s. indexOf ("Num"); //using indexOf () method on string object ...

    System. out. println (l);

    }

    }

    Output:-

    3
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “What method of the String object searches the string for an occurence of the specified search string? the charAt () method the search () ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers