Menu
Question Index
...

What will be the output of the following program?

public class McSample {
    public static void main(String[] args) {
        StringBuffer stringBuffer1 = new StringBuffer(10);
        CharSequence cs = "MeritCampus";
        StringBuffer stringBuffer2 = new StringBuffer("MERIT CAMPUS");
        StringBuffer stringBuffer3 = new StringBuffer(1);
        StringBuffer stringBuffer4 = new StringBuffer(cs);
        System.out.println(stringBuffer1 + "-" + stringBuffer2 + "-" + stringBuffer3 + "-" + stringBuffer4.toString());
    }
}


-MERIT CAMPUS--
-MERIT CAMPUS--MeritCampus
Compilation Error
Runtime Error

Doubts

Problems

Topic: Java StringBuffer

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App