Menu
Topics Index
...
`

Mughal architecture2280


If you need explanation Read this topic

If you need Answer Take test on this topic

Mughal architecture2280
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);
        name = architecture;
        System.out.println(name);
        architecture.setLength(3);
        System.out.println(architecture);
    }
}

A. Taj Mahal
Taj Mahal
B. Taj Mahal
Taj
C. Compilation Error
D. Runtime Error
Topic: Java setLength() Method In StringBuffer Class

If you need explanation Read this topic

If you need Answer Take test on this topic

User comments below. All of them might not be correct.

ans C an incompatability error will occur b'coz stringbuffer cannot be changed to string

Posted by Karthik Narahari    2014-01-31 13:25:08


Ans-C

Posted by Kick Bhasha    2014-01-31 13:25:26


Ans is b as it prnts taj mahal n later in the next line it sets length as 3 so it prints taj so ans is b

Posted by Lavanya Kategaru    2014-02-01 03:34:01


b

Posted by Harsha Harry    2014-02-02 10:22:23


Congratulations Karthik Narahari. You are this dose winner. We will send you the link using which you can claim your recharge.

Posted by Merit Campus    2014-02-03 04:37:05


© meritcampus 2019

All Rights Reserved.

Open In App