外企Java笔试题

2014-10-27 06:30:02 阅读( 70 )

2789人 收藏本页

标签:Java面试题

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?

来自IT公司面试手册

下一篇:J2EE面试题集

上一篇:关于Java基础的几个问题

亲~ 如果您有更好的答案 可在评论区发表您独到的见解。

您想查看更多的信息: 面试题