Output Questions for Class 10 ICSE Computer Applications
Give the output of the following string functions:
"DEDICATE".compareTo("DEVOTE")
Java
Java String Handling
ICSE 2018
92 Likes
Answer
-18
Working
"DEDICATE" and "DEVOTE" differ at the third character with 'D' and 'V', respectively. So, output of compareTo()
method will be ASCII Code of 'D' - ASCII Code of 'V' ⇒ 68 - 86 ⇒ -18.
Answered By
54 Likes