Advertisements
Advertisements
प्रश्न
Give the output of the following program segment:
String S = "GRACIOUS”.substring(4);
System.out.println(S);
System.out.println ("GLAMOROUS”.endsWith(S));
दीर्घउत्तर
Advertisements
उत्तर
IOUS
false
String S = “GRACIOUS”.substring(4);
Thesubstring(4)The method begins extraction from the character at index 4 (where ‘G’ is index 0). In the string “GRACIOUS”, the character at index 4 is ‘I’. Therefore, the value stored inSisIOUS.System.out.println(“GLAMOROUS”.endsWith(S));
TheendsWith()The method checks if the string “GLAMOROUS” ends with the suffix “IOUS”. Since “GLAMOROUS” ends with "ROUS" and not "IOUS", the condition is false. Thus, it printsfalse.
shaalaa.com
या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
