Computer Applications
Output of the following statement is …………… .
System.out.println("SUNDAY".substring(3));
- NDA
- DAY
- SUN
- N
Java String Handling
6 Likes
Answer
DAY
Reason — The substring() method returns a substring of the given string, which begins with the character at the specified start index and extends to the end of the string.
Here, the start index is 3 so the substring starts from 'D' and continues till the end of the string. So, the substring returned is "DAY".
Answered By
1 Like
Related Questions
Which one of the given statements is true for the following statement? string1.compareTo(string2)
- if string1 > string2 the result will be a positive integer i.e. > 0.
- if string1 < string2 the result will be a negative integer i.e. < 0.
- if string1 = string2 the result will be 0 i.e. = 0.
- all of these
The valueOf() method returns the …………… .
- string representation of the argument
- int representation of the argument
- boolean representation of the argument
- character representation of the argument
Output of the following statement is …………… .
System.out.println("WONDERFUL".substring(3,4));
- DERF
- NDER
- D
- N
How do you create strings implicitly and explicitly?