About Question enthuware.ocajp.i.v7.2.1284 :
Posted: Wed Apr 04, 2012 11:03 pm
Look at this question:
Pay attention on the call of the method replaceStringBuffer(s2). There is no such a method. The method that should've been called was replaceStringBuilder, so the correct answer is 'None of the above' instead 'javajavac'
Thanks
Code: Select all
public class Sample{
public static void main(String[] args) {
String s1 = new String("java");
StringBuilder s2 = new StringBuilder("java");
replaceString(s1);
replaceStringBuffer(s2);
System.out.println(s1 + s2);
}
static void replaceString(String s) {
s = s.replace('j', 'l');
}
static void replaceStringBuilder(StringBuilder s) {
s.append("c");
}
}
Thanks