Multiple choice

Which of the following methods cannot be used with the object of String class?

  1. replace(char, char)

  2. replaceAll(String, String)

  3. append(String)

  4. Both (1) and (2)

  5. All of these

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

This is the correct answer. Because the String class objects are immutable (i.e once the object of the String class is created its contents cannot be changed). So we cannot append new characters or string in the old string. So this is the correct answer.