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

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

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

    我的漫漫程序之旅

    專注于JavaWeb開(kāi)發(fā)
    隨筆 - 39, 文章 - 310, 評(píng)論 - 411, 引用 - 0
    數(shù)據(jù)加載中……

    華為面試題詳解(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);
    }

    }

    此題結(jié)果為:1234;
    比較簡(jiǎn)單分析下內(nèi)存就行了.

    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');
            }

        }


    }
    此題結(jié)果為:ABDCBDCB

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

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

    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; }

    此題考查的是繼承重寫(xiě)問(wèn)題.
    當(dāng)一個(gè)子類重寫(xiě)父類的方法時(shí),重寫(xiě)的方法的訪問(wèn)權(quán)限
    必須大于等于父類的訪問(wèn)權(quán)限.
    在此題中父類中的方法訪問(wèn)權(quán)限為protected,子類只能是
    protected或public.這時(shí)A是符合題意的.
    由于選項(xiàng)C的形參和父類的不一樣,沒(méi)有重寫(xiě)的效果,所以
    在子類出現(xiàn)也是沒(méi)問(wèn)題的.
    所以此題選: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.
    內(nèi)部類的實(shí)例化可以在普通方法里也可以在
    static方法里實(shí)例化.
    如下:
    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?

    (譯:那個(gè)方法是servlet用于將其session ID入在一個(gè)URL中,該URL寫(xiě)入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.
    此題選B.
    請(qǐng)看J2EE API關(guān)于此方法的說(shuō)明:
    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 々上善若水々 閱讀(4830) 評(píng)論(6)  編輯  收藏 所屬分類: Java筆試與面試

    評(píng)論

    # re: 華為面試題詳解(1~5)[未登錄](méi)  回復(fù)  更多評(píng)論   

    第三題答案再確認(rèn)一下
    2012-01-28 11:44 | xx

    # re: 華為面試題詳解(1~5)[未登錄](méi)  回復(fù)  更多評(píng)論   

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

    # re: 華為面試題詳解(1~5)[未登錄](méi)  回復(fù)  更多評(píng)論   

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

    # re: 華為面試題詳解(1~5)[未登錄](méi)  回復(fù)  更多評(píng)論   

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

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

    <table>

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

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

    <html>
    <body>
    測(cè)試一下
    </body>
    </html>
    2013-06-18 16:52 | <br>
    主站蜘蛛池模板: 最近中文字幕免费mv视频7| 免费一区二区三区四区五区| 亚洲AⅤ永久无码精品AA| 国产成A人亚洲精V品无码| 亚洲国产乱码最新视频| 国产97视频人人做人人爱免费| 精品国产污污免费网站aⅴ | 日韩精品视频免费网址| 国产亚洲精品a在线无码| 亚洲欧洲日韩国产一区二区三区| 国产精品免费αv视频| 无码一区二区三区AV免费| 亚洲日产韩国一二三四区| 亚洲午夜福利在线视频| 免费人成毛片动漫在线播放| 日韩在线a视频免费播放| 亚洲精品福利视频| 免费人人潮人人爽一区二区| 日本免费人成在线网站| 国产亚洲老熟女视频| 亚洲私人无码综合久久网| 免费毛片a线观看| 亚洲av日韩片在线观看| 亚洲午夜精品国产电影在线观看| 国产区在线免费观看| 热久久精品免费视频| 亚洲第一页在线播放| 男女拍拍拍免费视频网站| 浮力影院第一页小视频国产在线观看免费 | 亚洲成电影在线观看青青| 久久成人18免费网站| 免费观看的a级毛片的网站| 亚洲尹人香蕉网在线视颅| 国产成人无码免费网站| 日韩在线天堂免费观看| 亚洲国产品综合人成综合网站| 丝袜足液精子免费视频| 亚洲国产成人五月综合网 | 美女羞羞免费视频网站| 91嫩草国产在线观看免费| 亚洲资源在线观看|