Multiple choice

Which of the following methods is used to preallocate room for a certain number of characters after a StringBuffer has been constructed?

  1. setLength()

  2. charAt()

  3. ensureCapacity()

  4. none of these

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

This method is used to preallocate room for a certain number of characters after a StringBuffer has been constructed.