当前位置

首页 > 文学百科 > 面试技巧 > 华为的JAVA面试题

华为的JAVA面试题

推荐人: 来源: 阅读: 6.89K 次

华为的JAVA面试题(后记:没有想到华为的面试题就是非同一般,很多题不是一眼就能够看得出来,至少对我这种鸟来说是这样。对我个人来说,看看这样的题,可能比看《Think In Java》都还要好,因为这里面有很多的东西,都是我们平时没有太在意,或者是只是懂一点皮毛而已,通过做一下这样的练习,把自己不知道、不熟悉的知识点,利用这个机会好好的巩固一下。这些答案是我自己做的,有一些是从网上来的,有一部是自己做的,并且还有一部份没有做完,我不敢保证都对,所以请你在引用的时候,务必通过自己核对一下。当然,我既然能够把这些答案放在这里,那说明我肯定是自己检验了一遍的,也不是那么恐怖的)QUESTION NO: 1publicclassTest1 {publicstaticvoidchangeStr(String str){ str="welcome"; }publicstaticvoidmain(String[] args) { String str="1234";changeStr(str); tln(str); } } //输出结果:1234 //这里虽然是一个静态方法,但是里面的.变量是一个局部变量, //所以这里不因为是静态方法,就误认为里面的变量也是静态变量了QUESTION NO:2publicclassTest2 {staticbooleanfoo(charc) { t(c);returntrue; }publicstaticvoidmain(String[] argv) {inti = 0; //for(65;88&&(i<2);67) for(foo(A);foo(B) && (i < 2);foo(C)) { i++;foo(D); } } }QUESTION NO: 31. class A { 2. protected int method1(int a, int b) { return 0; } 3. } Which two are valid in a class that extends class A? (Choose two) A. public int method1(int a, int b) { return 0; } B. private int method1(int a, int b) { return 0; } C. private int method1(int a, long b) { return 0; } D. public short method1(int a, int b) { return 0; } E. static protected int method1(int a, int b) { return 0; }publicclassBextendsA{ //can not reduce the visibility of the inherited method from A //即不能够使从类A中继续来的方法的可见性降低 //private int method1(int a, int b) { return 0; } //This static method cannot hide the instance method from A //静态方法不能够隐藏继承于A的实例 //static protected int method1(int a, int b) { return 0; } //返回类型与A中的该方法不一致 //public short method1(int a, int b) { return 0; } //这里是写了一个重载方法,因为参数类型不一致,不会报错privateintmethod1(inta,longb) {return0; } //可见性可以增大,但是不能够缩小,正确publicintmethod1(inta,intb) {return0; }publicstaticvoidmain(String[] args) { //TODOAuto-generated method stub } }QUESTION NO: 41. public class Outer{ 2. public void someOuterMethod() { 3. // Line 3 4. } 5. public class Inner{} 6. public static void main( String[]argv ) { 7. Outer o = new Outer(); 8. // Line 8 9. } 10. } Which instantiates an instance of Inner? A. new Inner(); // At line 3 B. new Inner(); // At line 8 C. new r(); // At line 8 D. new r(); // At line 8//new Outer() Inner() 答案如下:publicclassOuter {publicvoidsomeOuterMethod() { // Line 3newInner();//放在这里不出错 }publicclassInner { }publicstaticvoidmain(String[] argv) { Outer o=newOuter(); // Line 8 //o不能够被解释成为一种类型,出错 //new r(); //new r(); //new Inner(); } }QUESTION NO: 5Which method is used by a servlet to place its session ID in a URL that is written to the servlet’s response output stream? (译:那个方法是servlet用于将其session ID入在一个URL中,该URL写入servlet的响应输出流) A. The encodeURL method of the HttpServletRequest interface. B. The encodeURL method of the HttpServletResponse interface. C. The rewriteURL method of the HttpServletRequest interface. D. The rewriteURL method of the HttpServletResponse TION NO: 6Which two are equivalent? (Choose two) A.

华为的JAVA面试题

赞助商

赞助商