What will the following program print when run?.
public class Main { private static void putO(StringBuilder s1) { s1 = s1.append("O"); }/*w w w.j a va2s . c o m*/ public static void main(String[] args) { StringBuilder s1 = new StringBuilder("W"); putO(s1); s1.append("W!"); System.out.println(s1); } }
Select the one correct answer.
(b)
The call to the putO()
method changes the StringBuilder object referred to by the s1 reference in the main()
method.
So does the call to the append()
method.