हिंदी

Give the output of the following program segment: String S = "GRACIOUS”.substring(4); System.out.println(S); System.out.println ("GLAMOROUS”.endsWith(S));

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
  1. String S = “GRACIOUS”.substring(4);
    The substring(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 in S is IOUS.
  2. System.out.println(“GLAMOROUS”.endsWith(S));
    The endsWith() 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 prints false.
shaalaa.com
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
2025-2026 (March) Official Board Paper
Advertisements
Share
Notifications



      Forgot password?
Use app×