Menu
Question Index
...

What will be the output of the following program?

public class Thomas {
    public static void main(String[] args) {
        StringBuffer data;
        String inventor = "Thomas Alva Edison";
        data = new StringBuffer();
        System.out.println(inventor + " Capacity " + data.capacity() + ".");
        data = new StringBuffer(inventor);
        System.out.println(inventor + " Capacity " + data.capacity() + ".");
    }
}


Thomas Alva Edison Capacity 16.
Thomas Alva Edison Capacity 34.
Thomas Alva Edison Capacity 0.
Thomas Alva Edison Capacity 18.
Compilation Error
Runtime Error

Doubts

Problems

Topic: Java StringBuffer length() And capacity() Methods

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App