You need to understand if an instance of an abstract class can be created in PHP. What would be your conclusion?
- It can be created
- It cannot be created
- It depends on the code
- None of the above
No, an instance of an abstract class cannot be created in PHP. Abstract classes are incomplete and serve as blueprints or templates for other classes. They cannot be instantiated directly because they may contain abstract methods that need to be implemented in the child classes. Attempting to create an instance of an abstract class will result in a runtime error. To utilize the functionality of an abstract class, you need to create an instance of a concrete child class that extends the abstract class. To know more, refer to: http://php.net/manual/en/language.oop5.abstract.php
Loading...
Related Quiz
- Which of the following are valid ways to denote a comment in PHP?
- You are writing a PHP script and you need to define a trait. How would you do this?
- The $GLOBALS superglobal in PHP is an associative array.
- What are some common practices in PHP when working with MySQL databases?
- In PHP, the values in an array are always stored in the order in which they were added.