- 相關(guān)推薦
華為的JAVA面試題
華為的JAVA面試題(后記:沒有想到華為的面試題就是非同一般,很多題不是一眼就能夠看得出來,至少對(duì)我這種鳥來說是這樣。對(duì)我個(gè)人來說,看看這樣的題,可能比看《Think In Java》都還要好,因?yàn)檫@里面有很多的東西,都是我們平時(shí)沒有太在意,或者是只是懂一點(diǎn)皮毛而已,通過做一下這樣的練習(xí),把自己不知道、不熟悉的知識(shí)點(diǎn),利用這個(gè)機(jī)會(huì)好好的鞏固一下。這些答案是我自己做的,有一些是從網(wǎng)上來的,有一部是自己做的,并且還有一部份沒有做完,我不敢保證都對(duì),所以請(qǐng)你在引用的時(shí)候,務(wù)必通過自己核對(duì)一下。當(dāng)然,我既然能夠把這些答案放在這里,那說明我肯定是自己檢驗(yàn)了一遍的,也不是那么恐怖的)QUESTION NO: 1publicclassTest1 {publicstaticvoidchangeStr(String str){ str="welcome"; }publicstaticvoidmain(String[] args) { String str="1234";changeStr(str); System.out.println(str); } } //輸出結(jié)果:1234 //這里雖然是一個(gè)靜態(tài)方法,但是里面的變量是一個(gè)局部變量, //所以這里不因?yàn)槭庆o態(tài)方法,就誤認(rèn)為里面的變量也是靜態(tài)變量了QUESTION NO:2publicclassTest2 {staticbooleanfoo(charc) { System.out.print(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中繼續(xù)來的方法的可見性降低 //private int method1(int a, int b) { return 0; } //This static method cannot hide the instance method from A //靜態(tài)方法不能夠隱藏繼承于A的實(shí)例 //static protected int method1(int a, int b) { return 0; } //返回類型與A中的該方法不一致 //public short method1(int a, int b) { return 0; } //這里是寫了一個(gè)重載方法,因?yàn)閰?shù)類型不一致,不會(huì)報(bào)錯(cuò)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 o.Inner(); // At line 8 D. new Outer.Inner(); // At line 8//new Outer().new Inner() 答案如下:publicclassOuter {publicvoidsomeOuterMethod() { // Line 3newInner();//放在這里不出錯(cuò) }publicclassInner { }publicstaticvoidmain(String[] argv) { Outer o=newOuter(); // Line 8 //o不能夠被解釋成為一種類型,出錯(cuò) //new o.Inner(); //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 servlet’s response output stream? (譯:那個(gè)方法是servlet用于將其session ID入在一個(gè)URL中,該URL寫入servlet的響應(yīng)輸出流) 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.
【華為的JAVA面試題】相關(guān)文章:
親歷華為面試06-18
華為面試經(jīng)歷06-18
華為面試問題03-24
華為幾號(hào)發(fā)工資04-19
華為都有哪些部門02-28
華為資格面試內(nèi)容08-10
華為d2怎么樣,華為d2好嗎?08-01
c面試題08-04