Menu
Question Index
...

What will be the output of the following program?

public class AppendMethod {
    public static void main(String args[]) {
        StringBuffer sb = new StringBuffer("Electrical ");
        System.out.println("Before Append: " + sb);
        sb.append("and Electronics ");
        System.out.println("After Append: " + sb);
        sb.append("Engineering");
        System.out.print(sb);
    }
}


Before Append: Electrical
After Append: Electrical and Electronics
Electronics Engineering
Before Append: Electrical
After Append: Electrical and Electronics
Engineering
Before Append: Electrical
After Append: Electrical and Electronics
Electrical and Electronics Engineering
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