Page 1 of 1

About Question enthuware.ocajp.i.v7.2.1284 :

Posted: Wed Apr 04, 2012 11:03 pm
by ETS User
Look at this question:

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");
  }
}
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

Re: About Question enthuware.ocajp.i.v7.2.1284 :

Posted: Thu Apr 05, 2012 6:40 am
by admin
You are right. This has now been fixed.

thank you for your feedback!