Menu
Question Index
...

What will be the output of the following program?

public class AppendMethods {
    public static void main(String args[]) {
        StringBuffer buf = new StringBuffer("Append char Array: ");
        char[] c = new char[]{'A', 'P', 'P', 'L', 'E'};
        buf.append(c);
        buf.append("Append boolean: ");
        boolean flag = true;
        buf.append(flag);
        buf.append("\n");
        buf.append("Append int: ");
        int i = 10;
        buf.append(i);
        System.out.println(buf.toString());
    }
}


Append char Array: APPLE
Append boolean: true
Append int: 10
Append char Array: APPLEAppend boolean:
Append int: 10
Append char Array: APPLEAppend boolean: true
Append int: 10
Compilation Error or Runtime Error

Doubts

Problems

Topic: Java append() Method In StringBuffer

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App