Give the output of the following program segment:

ICSE Class 10 Computer Applications PYQ · 2026 Paper · Section A

2(v)1 Mark · 2026 · Section A · 2026 Paper

Give the output of the following program segment:

String S = "GRACIOUS".substring(4);
System.out.println(S);
System.out.println("GLAMOROUS".endsWith(S));
Show SolutionHide Solution↓
IOUS
false
  • The substring() method is used to extract a part of a string starting from a specified index. In the given statement, "GRACIOUS".substring(4) extracts characters from index 4 to the end, resulting in "IOUS".

  • The endsWith() method checks whether a string ends with a specified sequence of characters and returns a boolean value. Here, "GLAMOROUS".endsWith("IOUS") checks if the string ends with "IOUS", which is false, so it prints false.

← Previous questionNext question →

Browse the free Computer Applications sample bank