String Methods

AP Computer Science A· difficulty 3/5

<code>"hi".charAt(2)</code> causes

  • A

    Returns 'i'

  • B

    Throws StringIndexOutOfBoundsException

    check_circle
  • C

    Returns -1

  • D

    Returns null character

Explanation

Valid indices: 0..length-1 = 0..1; index 2 is out of bounds.

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

Related questions