Bird
0
0

What happens if you try to extend a final class in PHP?

easy📝 Conceptual Q1 of 15
PHP - Inheritance and Polymorphism
What happens if you try to extend a final class in PHP?
AThe final class becomes abstract automatically.
BThe child class inherits all methods normally.
CThe child class can override final methods.
DIt causes a fatal error and the script stops.
Step-by-Step Solution
Solution:
  1. Step 1: Understand the meaning of final class

    A final class cannot be extended by any other class in PHP.
  2. Step 2: Check what happens when extending a final class

    Trying to extend a final class causes a fatal error and stops the script.
  3. Final Answer:

    It causes a fatal error and the script stops. -> Option D
  4. Quick Check:

    final class extension = fatal error [OK]
Quick Trick: Final classes cannot be extended; trying causes error [OK]
Common Mistakes:
  • Thinking final classes can be extended
  • Assuming final classes become abstract
  • Believing final methods can be overridden

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes