Which of the following methods modify the object on which they are called?
Select 1 option
A. setValue (int)of java.lang.Integer class. B. The substring (int) method of the String class C. The replace () method of the String class. D. The reverse () method of the StringBuffer class. E. None of these.
Correct Option is : D
For Option A.
There is no such method in Integer class.
Note that Integer, Float and other such wrapper objects are immutable.
For Option B.
String is an immutable object. calling substring(...) returns a new different String object. It cannot change the original object.
For Option C.
String objects can never be modified once created.