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));
- jeev
- Ra
- Raj
- 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
What is the output of the following Java code?
boolean flag = false; if (flag) { System.out.println("True"); } else { System.out.println("False"); }- True
- False
- No output
- Compilation error
Identify the static method from the list given below:
- length()
- nextLine()
- substring(int)
- isLetter(char)
System.out.println(Math.round(Math.ceil(-8.8)));will result in:- 8.0
- -8.0
- -9
- -8
Which one of the following Java statements assign 100 to the last element of a 3 × 3 array?
- x[2][2]=100;
- x[3][3]=100;
- x[2][3]=100;
- x[3][2]=100;