Prashnikaप्रश्निका
Code
About
‹ Back to the paper

Question 2

1 mark

Computer ScienceISC Computer Science - Competency Focused Practice Questions (CISCE, August 2024)MCQArrays, Strings

Choose the correct option.

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

  • (a)mutate object m.
  • (b)mutate object n.
  • (c)mutate both the objects m and n.
  • (d).append( ) is an accessor method so it cannot mutate any object.

Answer

Answer

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.