(vii)
Give the output of the following String class methods:
(a) "COMMENCEMENT".lastIndexOf('M')
(b) "devote" . compareTo("DEVOTE")
Solution
(a) 8
(b) Here compareTo() function returns the difference in two strings if they are not equal,if they are equal then returns zero
So,"devote" . compareTo("DEVOTE") 100-68
32