Menu
Topics Index
...
`

StringBuilder


If you need explanation Read this topic

If you need Answer Take test on this topic

StringBuilder
What will be the output of the following program?
public class A {
    public static void main(String args[]) {
        StringBuilder sb = new StringBuilder("Good Morning");
        sb.insert(1, "Friend ");
        System.out.println(sb);
    }
}

A. Good Morning
B. Friend Good Morning
C. Friend ood Morning
D. Some other output
E. Compilation Error or Runtime Error
Topic: StringBuilder Class In Java

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.

D.some other output .as Gfriendood Morning.as insert gives first G then friend the remaining string continues here.

Posted by Shabaaz Shaikz    2013-12-20 03:38:49


Ans D, Output is -- GFriendood Morning. here sb object inserts 'friend' string at index 1 ..

Posted by Mallikarjuna Rao    2013-12-20 04:13:11


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

Posted by Merit Campus    2013-12-23 05:03:36


:-)

Posted by Shabaaz Shaikz    2013-12-23 06:26:59


© meritcampus 2019

All Rights Reserved.

Open In App