PRASHNIKAप्रश्निका
‹ Back to the paper

m and n are two StringBuffer objects. The method call, m.append(n) will:

Computer Science20251 markMCQ
  • 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

AI

Correct 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.
Arrays, Strings

From ISC Computer Science - Competency Focused Practice Questions (CISCE, August 2024), question 2.