Menu
Question Index
...

What will be the output of the following program?

public class GoodEvening {
    public static void stringReplace(String text) {
        text = text.replace('j', 'c');
    }
    public static void bufferReplace(StringBuffer text) {
        text = text.append("c");
    }
    public static void main(String args[]) {
        String textString = new String("java");
        StringBuffer textBuffer = new StringBuffer("java");
        stringReplace(textString);
        bufferReplace(textBuffer);
        System.out.println(textString + textBuffer);
    }
}


javajavac
cavajavac
javac
java
Compilation Error or Runtime Error

Doubts

Problems

Topic: Java StringBuffer replace() Method With Example

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App