Home » JAVA Programming » Strings » Question
  1. What is the output of this program?
    public class Result 
    {
    public static void main(String args[])
    { String str = "Interview Mania";
    int K = str.indexOf('v');
    int L = str.lastIndexOf('i');
    System.out.print(K + " " + L);

    }
    }
    1. 13 5
    2. 3 5
    3. 5 13
    4. 5 3
    5. None of these
Correct Option: C

indexOf() method returns the index of first occurrence of the character where as lastIndexOf() returns the index of last occurrence of the character.



Your comments will be displayed only after manual approval.