外企Java笔试题

匿名网友 匿名网友 发布于: 2015-08-30 00:00:00
阅读 149 收藏 0 点赞 0 评论 0

1Which of the following fragments might cause errors? (5%)
  A. String s = “Gone with the wind”;
  String t = ” good “;
  String k = s + t;

  B. String s = “Gone with the wind”;
  String t;
  t = s[3] + “one”;

C. String s = “Gone with the wind”;
  String standard = s.toUpperCase();

  D. String s = “home directory”;
  String t = s – “directory”;

2 public class Parent { (5%)
  public int addValue( int a, int b) {
  int s;
  s = a+b;
  return s;
  }
  }
  class Child extends Parent {

  }
  Which methods can be added into class Child?
  A. int addValue( int a, int b ){// do something…}
  B. public void addValue (){// do something…}
  C. public int addValue( int a ){// do something…}
  D. public int addValue( int a, int b )throws MyException {//do something…}

3 Given: (5%)
Exhibit:
public class test {
public static void stringReplace (String text) {
text = text.replace (‘j’ , ‘i’);
}

public static void bufferReplace (StringBuffer text) {
text = text.append (“C”);
}

public static void main (String args[]} {
String textString = new String (“java”);
StringBuffer text BufferString = new StringBuffer (“java”);
stringReplace (textString);
bufferReplace (textBuffer);
System.out.printIn (textString + textBuffer);
}
}
What is the output?

评论列表
文章目录