public class
Test {
public static void main(
String args[]) {
StringBuffer a = new StringBuffer("One");
StringBuffer b = new StringBuffer("Two");
Test.swap(a,b);
System.out.println("a is "+ a +"\nb is " + b);
}
static void swap (StringBuffer a, StringBuffer b) {
a.append(" more");
b=a;
}
}
What will be the output?
Answer:
a. a is One
b is Two
b. a is One
b is One
c. a is One more
b is One more
d. a is One more
b is Two
e. a is One more
b is Two more
asnwer is d
i thougth answer is c
a.append(" more"); // now a is "One more"
b=a; // now b = a means b is also "One more"
Correct me where i am wrong ???