PHP物件導向-測試題(1~5)

來源:互聯網
上載者:User
    1. What is the construct used to define the blueprint of an object called?
    Your Answer: ____________________________    2. At the end of the execution of the following script, which values will be stored in the $a->my_value array? (Choose 3)
    <?php
    class my_class
    {
    var $my_value = array();
    function my_class ($value)
    {
    $this->my_value[] = $value;
    }
    function set_value ($value)
    {
    $this->$my_value= $value;
    }
    }
    $a = new my_class ('a');
    $a->my_value[] = 'b';
    $a->set_value ('c');
    $a->my_class('d');
    ?>
    A. c
    B. b
    C. a
    D. d
    E. e    3. How can you write a class so that some of its properties cannot be accessed from outside its methods?
    A. By declaring the class as private
    B. By declaring the methods as private
    C. It cannot be done
    D. By writing a property overloading method    4. Which object-oriented pattern would you use to implement a class that must be instantiated only once for the entire lifespan of a script?
    A. Model-view-controller
    B. Abstract factory
    C. Singleton
    D. Proxy
    E. State    5. A class can be built as an extension of other classes using a process known as inheritance. In PHP, how many parents can a child class inherit from?
    A. One
    B. Two
    C. Depends on system resources
    D. Three
    E. As many as needed

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.