✏️ Explanatory Question

Give the output of the following string functions:

  1. "MISSISSIPPI".indexOf('S') + "MISSISSIPPI".lastIndexOf('I')
  2. "CABLE".compareTo("CADET")

👁 78 Views
📘 Detailed Answer
🟢 Easy
💡

Answer with Explanation

  1. 2 + 10 = 12
  2. ASCII Code of B - ASCII Code of D
    ⇒ 66 - 68
    ⇒ -2