ICSE Class 10 Computer Applications Question 16 of 30

Solved 2024 Specimen Paper ICSE Class 10 Computer Applications — Question 16

Back to all questions
16
Question

Question 1(xvi)

The method compareTo() returns ............... when two strings are equal and in lowercase :

  1. true
  2. 0
  3. 1
  4. false
Answer

0

Reason — compareTo() method compares two strings lexicographically and returns the difference between the ASCII values of the first differing characters in the strings. Here, the strings are equal so the difference is 0.