多做题,通过考试没问题!

Java认证考试

睦霖题库>其他计算机考试>Java认证考试

Given this method in a class:  public String toString() {  StringBuffer buffer = new StringBuffer();  buffer.append(‟<‟);  buffer.append(this.name);  buffer.append(‟>‟);  return buffer.toString();  }  Which is true?() 

  • A、 This code is NOT thread-safe.
  • B、 The programmer can replace StringBuffer with StringBuilder with no other changes.
  • C、 This code will perform well and converting the code to use StringBuilder will not enhance the performance.
  • D、 This code will perform poorly. For better performance, the code should be rewritten: return “<“+ this.name + “>”;
正确答案:B
答案解析:
进入题库查看解析

微信扫一扫手机做题