Topics Index


If you need explanation Read this topic

If you need Answer Take test on this topic

Given a string constructed by calling s = new String("xyzzy"); which of the calls modifies the string?
A. s.append("aaa");
B. s.trim();
C. s.substring(3);
D. s.replace('z', 'a');
E. s.concat(s);
F. None of the above
Topic: Conclusion Of Strings 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.

F strings can't be modified if we want want modify string we use StringBuffer class

Posted by Ramkumar Boggarapu    2013-12-24 03:31:57

Ans is C or D or E.. substring replace and concat are the methods in Strings where append is nt..

Posted by Om Prakash Om    2013-12-24 03:39:20

ans is "D" bcoz it replasces which is modifies the ansr. dats wat askd in que...

Posted by Karthik Kulkarni    2013-12-24 03:42:01

D becocz string is a mutable objcet so we cant change

Posted by Rajashekar Chelpuri    2013-12-24 04:05:13

Ans:C because String class doesn't exist these replace method, for it builder have to use, and append n concat doesn't give results becoz strings are mutable.

Posted by Shreenath Chandrakanth    2013-12-24 04:35:42

Ans is E,none of the above calls modifies the string.

Posted by Ankit Mudiraj    2013-12-24 07:17:44

answer is 'F' string class objects are immutable all the methods above will return a new string but they won't modify the actual string

Posted by Sai Teja    2013-12-25 02:46:37

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

Posted by Merit Campus    2013-12-25 03:53:41

© meritcampus 2019

All Rights Reserved.

Open In App