What will the following code print when compiled and run?
public class Main { public static void main (String [] args) { String s = "A"; StringBuilder sb = new StringBuilder (s); s.append ("B"); sb .append ("C"); // w ww . ja va 2 s .com System .out.println (s); System .out.println (sb); } }
Select 1 option
Correct Option is : D
append () method does not exist in String class.
It exits only in StringBuffer and StringBuilder. The value of sb will be AC though.