<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    我的漫漫程序之旅

    專注于JavaWeb開發
    隨筆 - 39, 文章 - 310, 評論 - 411, 引用 - 0
    數據加載中……

    華為面試題詳解(1~5)

    1.
    public class Test {
    public static void changeStr(String str){
    str
    ="welcome";
    }

    public static void main(String[] args) {
    String str
    ="1234";
    changeStr(str);
    System.out.println(str);
    }

    }

    此題結果為:1234;
    比較簡單分析下內存就行了.

    2.
    public class ForTest
    {
        
        
    static boolean foo(char c)
        
    {
            System.out.println(c);
            
    return true;
        }

        
        
    public static void main(String[] args)
        
    {
            
    int i = 0;
            
    for(foo('A');foo('B')&&(i<2);foo('C'))
            
    {
                i 
    ++;
                foo(
    'D');
            }

        }


    }
    此題結果為:ABDCBDCB

    這道題考查的for循環的執行順序.
    for(int i  = 0; i < 10; i ++)
    {}
    首先先執行int i = 0;注意這個只是初始化一次,
    就是在第一次的時候.接著執行i < 10;
    然后執行方法體{}里面的內容,最后才執行i++;

    第二次及以后就直接執行i <10;然后方法體;最后
    i ++;如此順序直到結束為止.

    3.
    1class A {
    2protected 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; }

    此題考查的是繼承重寫問題.
    當一個子類重寫父類的方法時,重寫的方法的訪問權限
    必須大于等于父類的訪問權限.
    在此題中父類中的方法訪問權限為protected,子類只能是
    protected或public.這時A是符合題意的.
    由于選項C的形參和父類的不一樣,沒有重寫的效果,所以
    在子類出現也是沒問題的.
    所以此題選:AC

    4.
    1public class Outer{
    2public void someOuterMethod() {
    3// Line 3
    4. }

    5public class Inner{}
    6public 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()

    此題選A.
    內部類的實例化可以在普通方法里也可以在
    static方法里實例化.
    如下:
    package com.test.a;

    public class Outer
    {
        Inner i 
    = new Outer.Inner();
        
        
    public void method()
        
    {
            
    new Inner();
        }

        
        
    public class Inner{
        }

        
    public static void main(String[] args)
        
    {
            Outer o 
    = new Outer();
            Inner i 
    =  o.new Inner();
        }

        
        
    static void a()
        
    {
            Outer o 
    = new Outer();
            Inner i 
    = o.new Inner();
        }


    }

    5.
    Which 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 
    interface.
    此題選B.
    請看J2EE API關于此方法的說明:
    Encodes the specified URL for use in the sendRedirect method or, if encoding is not needed, returns the URL unchanged. The implementation of this method includes the logic to determine whether the session ID needs to be encoded in the URL. Because the rules for making this determination can differ from those used to decide whether to encode a normal link, this method is separated from the encodeURL method. 
    All URLs sent to the HttpServletResponse.sendRedirect method should be run through 
    this method. Otherwise, URL rewriting cannot be used with browsers which do not support cookies. 


    posted on 2007-12-13 09:37 々上善若水々 閱讀(4853) 評論(6)  編輯  收藏 所屬分類: Java筆試與面試

    評論

    # re: 華為面試題詳解(1~5)[未登錄]  回復  更多評論   

    第三題答案再確認一下
    2012-01-28 11:44 | xx

    # re: 華為面試題詳解(1~5)[未登錄]  回復  更多評論   

    第三題C不對吧 Cannot reduce the visibility of the inherited method
    2013-05-08 15:11 | 123

    # re: 華為面試題詳解(1~5)[未登錄]  回復  更多評論   

    第三題C不對吧 Cannot reduce the visibility of the inherited method
    2013-05-08 15:11 | 123

    # re: 華為面試題詳解(1~5)[未登錄]  回復  更多評論   

    第三題C不對吧 Cannot reduce the visibility of the inherited method
    2013-05-08 15:11 | 123

    # re: 華為面試題詳解(1~5)  回復  更多評論   

    <table>

    2013-06-18 16:51 | <html>

    # re: 華為面試題詳解(1~5)  回復  更多評論   

    <html>
    <body>
    測試一下
    </body>
    </html>
    2013-06-18 16:52 | <br>
    主站蜘蛛池模板: 乱淫片免费影院观看| 亚洲最大的黄色网| 国产精品福利片免费看| 麻豆国产VA免费精品高清在线| 亚洲AV成人噜噜无码网站| 亚洲精品视频在线免费| 亚洲精品免费在线视频| 免费AA片少妇人AA片直播| 亚洲免费观看网站| 成人免费a级毛片| 美国免费高清一级毛片| 国产L精品国产亚洲区久久| 中文字幕免费观看全部电影| 亚洲区小说区图片区QVOD| 国产午夜精品免费一区二区三区| 亚洲人成网址在线观看 | 亚洲人片在线观看天堂无码| 免费无码又爽又刺激高潮的视频 | 丰满妇女做a级毛片免费观看| 亚洲一级Av无码毛片久久精品| a毛片在线看片免费| 亚洲欧洲日产国产最新| 女人毛片a级大学毛片免费| 亚洲AV日韩AV天堂久久| 99在线视频免费观看视频 | 国产成人精品免费大全| 亚洲国产一区在线| 日本一区二区三区免费高清 | 成全动漫视频在线观看免费高清版下载| 亚洲国产精品线在线观看| 国产精品免费观看久久| 人人爽人人爽人人片av免费| 亚洲av不卡一区二区三区| 成年性羞羞视频免费观看无限| xvideos永久免费入口| 亚洲精品mv在线观看| 免费在线观看污网站| 亚洲人成免费电影| 一级黄色免费网站| 亚洲精品午夜在线观看| 国外亚洲成AV人片在线观看|