Which of the following String methods returns a negative value?

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

1(xvi)1 Mark · 2026 · Section A · 2026 Paper

Which of the following String methods returns a negative value?

Show SolutionHide Solution↓

compareTo()

Reason — The compareTo() method compares two strings lexicographically and returns an integer value which can be positive, zero, or negative depending on the comparison. The methods length() returns the length (non-negative), equals() returns a boolean, and charAt() returns a character, so none of them can return a negative value.

← Previous questionNext question →

Browse the free Computer Applications sample bank