PHP MCQ Quiz Hub

PHP Mcq– Basics of Object-Oriented PHP

Choose a topic to test your knowledge and improve your PHP skills

1. The practice of separating the user from the true inner workings of an application through well-known interfaces is known as _________




2. Which of the following term originates from the Greek language that means “having multiple forms,” defines OOP’s ability to redefine, a class’s characteristics?




3. The practice of creating objects based on predefined classes is often referred to as ______________




4. Which one of the following can be used to instantiate an object in PHP assuming class name to be Foo?




5. Which one of the following is the right way to define a constant?




6. Which one of the following is the right way to call a class constant, given that the class is mathFunction?




7. Which of the following is/are the right way to declare a method? i) function functionName() { function body } ii) scope function functionName() { function body } iii) method methodName() { method body } iv) scope method methodName() { method body }




8. . Which of the following method scopes is/are not supported by PHP? i) private ii) friendly iii) static iv) abstract




9. 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.




10. PHP recognizes constructors by the name _________




11. Which version of PHP introduced the instanceof keyword?




12. Which one of the following functions is used to determine whether a class exists?




13. Which one of the following functions is used to determine object type?




14. Which one of the following keyword is used to inherit our subclass into a superclass?




15. . In the following PHP code, what is/are the properties? <?php class Example { public $name; function Sample() { echo "This is an example"; } } ?>




16. Which keyword is used to refer to properties or methods within the class itself?




17. Which of the following advanced OOP features is/are not supported by PHP?




18. Which one of the following is the right way to clone an object?




19. Which of the following is/are true for an abstract class? i) Abstract classes in PHP are declared with the help of abstract keyword. ii) A class is declare abstract by using the keyword implements. iii) It is a class that really isn’t supposed to ever be instantiated but instead serves as a base class. iv) Attempting to instantiate an abstract class results in an error.




20. If one intends to create a model that will be assumed by a number of closely related objects, which class must be used?




21. Which method is used to tweak an object’s cloning behavior?




22. Which feature allows us to call more than one method or function of the class in single instruction?




23. Which magic method is used to implement overloading in PHP?