Menu
Topics Index
...
`

StringBuffer2888


If you need explanation Read this topic

If you need Answer Take test on this topic

StringBuffer2888
What will be the output of the following program?
public class Delete {
    public static void main(String[] args) {
        StringBuffer sb = new StringBuffer("This is Merit Campus program");
        StringBuffer str = sb.delete(14, 21);
        System.out.println(str);
        System.out.println(sb);
        sb.deleteCharAt('6');
        System.out.println(sb);
    }
}

A. Campus 
This is Merit program
Thisis Merit program
B. This is Merit program
This is Mersprogram
Thisis Merit program
C. This is Merit program
This is Merit program
This i Merit program
D. Compilation Error or Runtime Error
Topic: Java delete() and deleteCharAt() Methods In StringBuffer

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.

Answer is D : runtime exception as deleteCharAt method takes an invalid argument

Posted by Shashanka Mogaliraju    2014-08-18 12:52:06


ans D, the method deleteCharAt() fails to execute, because the passed parameter is not matched type.

Posted by Damu Surya    2014-08-18 12:53:38


D

bcoz one can only pass int as an argument in deleteCharAt() while in program character is passed

Posted by Nishant Desai    2014-08-18 14:47:06


d

Posted by Deepika Deepu    2014-08-18 16:15:23


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

Posted by Merit Campus    2014-08-19 04:32:35


© meritcampus 2019

All Rights Reserved.

Open In App