PHP MCQ Quiz Hub

PHP Mcq– Basics of Object-Oriented PHP

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

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





✅ Correct Answer: 3

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?





✅ Correct Answer: 2

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





✅ Correct Answer: 4

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





✅ Correct Answer: 3

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





✅ Correct Answer: 4

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





✅ Correct Answer: 3

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 }





✅ Correct Answer: 3

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





✅ Correct Answer: 1

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.





✅ Correct Answer: 3

PHP recognizes constructors by the name _________





✅ Correct Answer: 4

Which version of PHP introduced the instanceof keyword?





✅ Correct Answer: 2

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





✅ Correct Answer: 3

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





✅ Correct Answer: 3

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





✅ Correct Answer: 1

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





✅ Correct Answer: 2

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





✅ Correct Answer: 4

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





✅ Correct Answer: 3

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





✅ Correct Answer: 2

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.





✅ Correct Answer: 1

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





✅ Correct Answer: 3

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





✅ Correct Answer: 2

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





✅ Correct Answer: 4

Which magic method is used to implement overloading in PHP?





✅ Correct Answer: 1