String Methods

AP Computer Science A· difficulty 4/5

<code>"abcdef".substring(2, 5)</code> returns

  • A

    "abcde"

  • B

    "cdef"

  • C

    "cde"

    check_circle
  • D

    "bcd"

Explanation

substring(begin, end) is inclusive of begin, exclusive of end. Indices 2,3,4 → c,d,e → "cde".

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

Related questions