मराठी

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

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
  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
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×