ensureCapacity - Java Quiz Question


What will be the output of the following program?

public class StringBufferDemo {
    public static void main(String[] args) {
        StringBuffer firstBuffer = new StringBuffer("Merit Campus");
        System.out.println("First Buffer = " + firstBuffer);
        System.out.println("Old Capacity = " + firstBuffer.capacity());
        firstBuffer.ensureCapacity(27);
        System.out.println("New Capacity = " + firstBuffer.capacity());
    }
}


A
First Buffer = Merit Campus
Old Capacity = 16
New Capacity = 27
B
First Buffer = Merit Campus
Old Capacity = 28
New Capacity = 27
C
First Buffer = Merit Campus
Old Capacity = 28
New Capacity = 28
D
Compilation Error or Runtime Error