PHP object-oriented-Test Question (1 ~ 5)

Source: Internet
Author: 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.
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 wocould 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 needed

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.