Multiple choice

Which of the following functions pre-allocate room for a certain number of characters after a StringBuffer has been constructed?

  1. setLength()

  2. ensureCapacity()

  3. length()

  4. none of these

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

This function preallocate room for a certain number of characters after a StringBuffer has been constructed.