(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


Contact Us

REACH US

SERVICES

  • CODING
  • ON-LINE PREPARATION
  • JAVA & PYTHON

ADDRESS

B-54, Krishna Bhawan, Parag Narain Road, Near Butler Palace Colony Lucknow
Contact:+ 919839520987
Email:info@alexsir.com