Which of the following methods cause the String object referenced by s to be changed? (Select multiple)

A) s.concat( )
B) s.toUpperCase( )
C) s.replace( )
D) s.valueOf( )

Showing Answers 1 - 9 of 9 Answers

smalltalk

  • Apr 10th, 2006
 

None of them modify the object referenced by s since the first three create new String objects on the heap and reassign s to the newly created objects and the fourth method is static (in all its overloaded forms) and has nothing to do with the s reference or the object s refers to.

  Was this answer useful?  Yes

mavrick_joe

  • Apr 19th, 2006
 

I feel that all of them should be marked 'coz if we write s = s.concat() or any other method, then 'coz strings are immutable so a new string will be formed and hence the reference would change.

  Was this answer useful?  Yes

MD MERAJ AHMED

  • Jul 25th, 2017
 

A) s.concat( )

  Was this answer useful?  Yes

Ajay

  • Oct 24th, 2019
 

A. s.concat()
B.s.toUpperCase() is a right answer.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions