2020(招聘面试)大公司面试问题集锦

上传人:精****库 文档编号:133787545 上传时间:2020-05-30 格式:DOC 页数:83 大小:168.61KB
返回 下载 相关 举报
2020(招聘面试)大公司面试问题集锦_第1页
第1页 / 共83页
2020(招聘面试)大公司面试问题集锦_第2页
第2页 / 共83页
2020(招聘面试)大公司面试问题集锦_第3页
第3页 / 共83页
2020(招聘面试)大公司面试问题集锦_第4页
第4页 / 共83页
2020(招聘面试)大公司面试问题集锦_第5页
第5页 / 共83页
点击查看更多>>
资源描述

《2020(招聘面试)大公司面试问题集锦》由会员分享,可在线阅读,更多相关《2020(招聘面试)大公司面试问题集锦(83页珍藏版)》请在金锄头文库上搜索。

1、各公司面试题华为的JAVA面试题(后记:没有想到华为的面试题就是非同一般,很多题不是一眼就能够看得出来,至少对我这种鸟来说是这样。对我个人来说,看看这样的题,可能比看Think In Java都还要好,因为这里面有很多的东西,都是我们平时没有太在意,或者是只是懂一点皮毛而已,通过做一下这样的练习,把自己不知道、不熟悉的知识点,利用这个机会好好的巩固一下。这些答案是我自己做的,有一些是从网上来的,有一部是自己做的,并且还有一部份没有做完,我不敢保证都对,所以请你在引用的时候,务必通过自己核对一下。当然,我既然能够把这些答案放在这里,那说明我肯定是自己检验了一遍的,也不是那么恐怖的)QUESTIO

2、N NO: 1Public class Test1 Public static void changeStr(String str) str=welcome; Public static void main(String args) String str=1234; changeStr(str); System.out.println(str); /输出结果:1234/这里虽然是一个静态方法,但是里面的变量是一个局部变量,/所以这里不因为是静态方法,就误认为里面的变量也是静态变量了QUESTION NO:2Public class Test2 Static boolean foo(char c

3、) System.out.print(c); Return true; Public static void main(String argv) int i = 0; /for(65;88&(i2);67) for (foo(A); foo(B) & (i 2); foo(C) i+; foo(D); /*What is the result?A. ABDCBDCBB. ABCDABCDC. Compilation fails.D. An exception is thrown at runtime./输出结果是:ABDCBDCB分析:FOR循环里面讲究的条件要为真,与你的判断式是什么没有关系

4、就像这里,虽然是打印的字母,但是却不是false,所以可以执行第一次进行循环:foo(A)打印字母A,(注:这里不是false条件就默认为true条件)foo(B)打印字母B,i=0,比较(i 2),条件为true,进行循环体,foo(D)打印Dfoo(C)打印字母C第二次循环:foo(B)打印B,i=1,比较(i 2)为true,进行循环体,foo(D)打印Dfoo(C)打印字母C第三次循环:foo(B)打印字母B,i=2,比较(i 2)为false,退出循环,得结果*/ QUESTION NO: 31. class A 2. protected int method1(int a, int

5、 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 metho

6、d1(int a, int b) return 0; publicclass B extends A /*paramargs */ /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 metho

7、d1(int a, int b) return 0; /返回类型与A中的该方法不一致 /public short method1(int a, int b) return 0; /*总结:类的继承中,如果要想重载父类的方法,必须要和父类中的返回类型、可见性等等都要操作一致 *否则,程序就会报错。一定遵守子类要遵从于父类的原则 *而我选择的答案居然是privateintmethod1和staticprotectedint *我选择第一个的错误理由是:因为原来为保护的,如果我这里设为public,那么就扩展了其原来的可见性 *本来原来就是对包外不可见的,现在变成对包外可见的了,所以就选择的是pri

8、vate *选择第二个的错误理由是:都是保护的,这里只是变成了静态的而已*/ /这里是写了一个重载方法,因为参数类型不一致,不会报错 Private int method1(int a, long b) return 0; /可见性可以增大,但是不能够缩小,正确 Public int method1(int a, int b) return 0; Public static void main(String args) / TODO Auto-generated method stub QUESTION NO: 41. public class Outer2. public void some

9、OuterMethod() 3. / Line 34. 5. public class Inner6. public static void main( Stringargv ) 7. Outer o = new Outer();8. / Line 89. 10. Which instantiates an instance of Inner?A. new Inner(); / At line 3B. new Inner(); / At line 8C. new o.Inner(); / At line 8D. new Outer.Inner(); / At line 8/new Outer(

10、).new Inner()答案如下:publicclass Outer publicvoid someOuterMethod() / Line 3 new Inner();/放在这里不出错 publicclass Inner publicstaticvoid main(String argv) Outer o= new Outer(); / Line 8 /o不能够被解释成为一种类型,出错 /new o.Inner(); /* *下面两种用法,都报下面的错误: *NoenclosinginstanceoftypeOuterisaccessible. *Mustqualifytheallocat

11、ionwithanenclosinginstance *oftypeOuter(e.g.x.newA()wherexisaninstanceofOuter) */ /new Outer.Inner(); /new Inner(); QUESTION NO: 5Which method is used by a servlet to place its session ID in a URL that is written to the servlets response output stream?(译:那个方法是servlet用于将其session ID入在一个URL中,该URL写入serv

12、let的响应输出流)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 interface.QUESTION NO: 6Which two are equivalent? (Choose two)A. B. C. D. E. F. G. QUESTION NO: 7Which of the following statements regarding the lifecycle of a session bean are correct? 1.java.lang.IllegalStateException is thrown if SessionContext.getEJBObject() is invoked when a stateful session bean instance is passivated. 2.SessionContext.getRollbac

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 商业/管理/HR > 企业文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号