Topics Index

StringBuffer its methods

If you need explanation Read this topic

If you need Answer Take test on this topic

StringBuffer its methods
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);

A. Campus 
This is Merit program
Thisis Merit program
B. Campus
This is Meritprogram
Thisis Merit program
C. This is Merit program
This is Mersprogram
Thisis Merit program
D. Some other output
E. 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.


Posted by Pothuluri Venkateswarlu    2014-06-23 13:40:16


Posted by Pothuluri Venkateswarlu    2014-06-23 13:40:37

Ans is D.14,21 campus wl deleted n deleteCharAt(4) space wil get out put is This is Merit Program This is Merit Program  Thisis Merit Program

Posted by Ch Chandrasekar    2014-06-23 13:44:24

Output will be:
This is merit program
This is merit program
Thisis merit program...
-------sb.delete(14,21)-- will delete campus n space before it as it deletes from index 14 to 21.
--------sb.deleteCharAt(4)--will delete the space after the word "this" as space is at index "4".

Posted by Mânïshå Mùlchåndânï    2014-06-23 15:43:25

ANS : D , first SOP prints " This is Merit Campus program" and after that second SOP prints "This is Meritprogram" ande then finally third SOP prints "Thisis Merit Campus program" so there is no maches with this output ,

Posted by Damu Surya    2014-06-23 17:45:20

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

Posted by Merit Campus    2014-06-24 04:02:32

© meritcampus 2019

All Rights Reserved.

Open In App