String Methods

AP Computer Science A· difficulty 3/5

<code>"hello".indexOf('z')</code> returns

  • A

    0

  • B

    Throws exception

  • C

    5

  • D

    −1

    check_circle

Explanation

<code>indexOf</code> returns -1 when the character is not found.

Want 10 more like this — adaptive to your weak spots?

Related questions