Computer Applications

Which one of the following will be the output of the below statements?

String a[]={"Rohini", "Rajarshi", "Rajeev", "Rehan", "Rebecca"}; 
System.out.println(a[2].substring(2));
  1. jeev
  2. Ra
  3. Raj
  4. je

Java

Java String Handling

7 Likes

Answer

jeev

Reason — In the array, the element at position 2 is "Rajeev". In Java, string indexing starts from 0, so index 0 = R, index 1 = a, and index 2 = j. Using substring(2) means we take all characters from index 2 to the end, giving "jeev".

Answered By

3 Likes


Related Questions