Advertisements
Advertisements
प्रश्न
Which of the following String methods returns a negative value?
विकल्प
length()equals()compareTo()charAt()
MCQ
Advertisements
उत्तर
compareTo()
Explanation:
compareTo() returns an int: a negative value if the first string is lexicographically less than the second, zero if they are equal, and a positive value if it is greater. For example, "COMPUTER".compareTo("SCIENCE") yields a negative result because 'C'comes before'S' in character order.
shaalaa.com
क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
2025-2026 (March) Official Board Paper
