Object oriented programming php mcq
This is the questions and answers section on "Object Oriented PHP" with the explanation for various interview, competitive examination and entrance test. Solved examples with detailed answer description, explanation are given and it would be easy to understand. Show Object Oriented PHP Questions
2. Which of the following statements is/are true about Constructors in PHP? (i) PHP 4 introduced class constructors. (ii) Constructors can accept parameters. (iii) Constructors can call class methods or other functions (iv) Class constructors can call on other constructors.
WorkspaceReport Error3. PHP recognizes constructors by the name.
Answer & ExplanationAnswer: Option D Explanation: A double underscore followed by the construct keyword. Its syntax is function __construct ([ argument1, argument2,.....]) { Class Initialization code } WorkspaceReport Error4. Which version of PHP introduced the instanceof keyword?
Answer & ExplanationAnswer: Option B Explanation: Using instanceof keyword we can determine whether an object is an instance of a class. $manager = new Employee() ¦ if ($manager instanceof Employee) echo "True; WorkspaceReport Error5. Which one of the following functions is used to determine whether a class exists?
Answer & ExplanationAnswer: Option C Explanation: The class_exist() function returns true or false according to whether the class exists within the currently executing script content. WorkspaceReport ErrorMock Tests & Online QuizzesThis set of PHP Multiple Choice Questions & Answers (MCQs) focuses on “Advanced Object-Oriented PHP”. 1. Which of the following advanced OOP features is/are not supported by PHP? a) i) Answer: c 2. Which version of PHP introduced the advanced concepts of OOP? Answer: b 3. Which one of the following is the right way to clone an
object? Answer: b 4. The class from which the child
class inherits is called ________ a) Only i) Answer: d 5. Which of the following is/are true for an abstract class? Answer: a 6. If one intends to create a model that will be assumed by a number of closely related objects, which class must be used? Answer: c 7. If your object must inherit behavior from a number of sources you must use a/an Answer: a 8. Which method is used to tweak an object’s cloning behavior? Answer: b 9. Which feature allows us to call more than one method or function of the class in single instruction? Answer: d $a = new Order(); $a->CreateOrder()->sendOrderEmail()->createShipment(); 10. Which magic method is used to implement overloading in PHP? Answer: a Sanfoundry Global Education & Learning Series – PHP Programming. To practice all questions on PHP Programming, here is complete set of 1000+ Multiple Choice Questions and Answers on PHP. Next Steps:
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn. Subscribe to his free Masterclasses at Youtube & technical discussions at Telegram SanfoundryClasses. |