‹ Back to the paper
m and n are two StringBuffer objects. The method call, m.append(n) will:
- amutate object m.
- bmutate object n.
- cmutate both the objects m and n.
- d.append( ) is an accessor method so it cannot mutate any object.
Answer
Answer
AICorrect option: a
Answer: (a) mutate object m.
StringBuffer's append(x) method modifies the StringBuffer it is called on by appending x's content to it. So m.append(n) appends n's characters onto m, mutating m; n itself is left unchanged.
From ISC Computer Science - Competency Focused Practice Questions (CISCE, August 2024), question 2.