Menu
Question Index
...

What will be the output of the following program?

public class HeroinNameIs {
    public static void main(String args[]) {
        StringBuffer buf = new StringBuffer();
        buf.append("Append String: ");
        String str = "Hansika";
        buf.append(str);
        buf.append("\n");
        buf.append("Append char: ");
        char c = 'r';
        buf.append(c);
        System.out.println(buf.toString());
    }
}


Append String: Hansika\nAppend char: r
Append String: Hansika
Append char: r
Compilation Error
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