Menu
Question Index
...

What will be the output of the following program?

public class TomAndJerry {
    public static void main(String[] args) {
        String tom = "cat";
        StringBuffer jerry = new StringBuffer(tom);
        System.out.print(jerry);
        jerry.setCharAt(0, r);
        System.out.print(" " + jerry);
    }
}


cat cat
cat rat
Compilation Error
Runtime Error

Doubts

Problems

Topic: Java charAt() And setCharAt() Methods 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