The output of the statement "CONCENTRATION".indexOf('T') is:

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

1(iii)1 Mark · 2024 · Section A · 2024 Paper

The output of the statement "CONCENTRATION".indexOf('T') is:

Show SolutionHide Solution↓

6

Reason — The method indexOf(char ch) in Java returns the index of the first occurrence of the specified character ch in the string. If the character is not found, it returns -1.

Consider the string:
"CONCENTRATION"

Let’s count the characters by their index (Java uses zero-based indexing):

CONCENTRATION
0123456789101112

The first occurrence of the character 'T' is at index 6.

Thus, the output of the statement "CONCENTRATION".indexOf('T') is 6.

← Previous questionNext question →

Share on WhatsApp

Browse the free Computer Applications sample bank