Menu
Question Index
...

What will be the output of the following program?

public class MughalArchitecture {
    public static void main(String[] args) {
        String name = "Taj Mahal";
        StringBuffer architecture = new StringBuffer(name);
        System.out.println(architecture);
        architecture.setLength(3);
        architecture = new StringBuffer(name);
        System.out.println(architecture);
    }
}


Taj Mahal
Taj Mahal
Taj Mahal
Taj
Compilation Error
Runtime Error

Doubts

Problems

Topic: Java setLength() Method In StringBuffer Class

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App