Home > PHP & Programming > Quizzes > PHP Programming Basics Practice Test: Object-Oriented PHP
PHP Programming Basics Practice Test: Object-Oriented PHP
Fast practice, instant feedback. Timer auto-submits when time’s up.
Avg score: 0% Most missed: “Which method scope prevents a method from being overridden by a subclass?”
PHP introduced object-oriented programming features since version 5.0. Object-Oriented programming is one of the most popular programming paradigms based on the concept of objects and classes. Object-oriented programming (OOP) is a programming paradigm in PHP that focuses on data and its associated functions. It involves creating objects that contain both data and functions. OOP has several advantages over procedural programming, including: Maintenance: OOP helps to keep code DRY ("Don't Repeat Yourself") and makes it easier to maintain, modify, and debug. Reusability: OOP makes it... Show more
PHP Programming Basics Practice Test: Object-Oriented PHP
Time left 00:00
25 Questions

1. Which keyword allows class members (methods and properties) to be used without needing to instantiate a new instance of the class?
2. The class from which the child class inherits is called ________
i) Child class
ii) Parent class
iii) Super class
iv) Base class
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 }
4. Which one of the following functions is used to determine whether a class exists?
5. Which of the following method scopes is/are not supported by PHP?
i) private
ii) friendly
iii) static
iv) abstract
6. Which one of the following property scopes is not supported by PHP?
7. In the following PHP code, what is/are the properties?

class Example
{
public $name;
function Sample()
{
echo "This is an example";
}
}
?>
8. Which one of the following is the right way to invoke a method?
9. If one intends to create a model that will be assumed by a number of closely related objects, which class must be used?
10. Which keyword is used to refer to properties or methods within the class itself?
11. The practice of creating objects based on predefined classes is often referred to as ______________
12. Which version of PHP introduced the advanced concepts of OOP?
13. Which of the following advanced OOP features is/are not supported by PHP?
i) Method overloading
ii) Multiple Inheritance
iii) Namespaces
iv) Object Cloning
14. The practice of separating the user from the true inner workings of an application through well-known interfaces is known as _________
15. Which one of the following is the right way to call a class constant, given that the class is mathFunction?
16. Which feature allows us to call more than one method or function of the class in single instruction?
17. Which method scope prevents a method from being overridden by a subclass?
18. If your object must inherit behavior from a number of sources you must use a/an
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. Which method is used to tweak an object’s cloning behavior?
21. Which one of the following keyword is used to inherit our subclass into a superclass?
22. Which version of PHP introduced the instanceof keyword?
23. Which one of the following functions is used to determine object type?
24. Which one of the following can be used to instantiate an object in PHP assuming class name to be Foo?
25. Which magic method is used to implement overloading in PHP?