Bird
0
0

Why might inheritance sometimes be avoided in PHP programming?

hard📝 Conceptual Q10 of 15
PHP - Inheritance and Polymorphism
Why might inheritance sometimes be avoided in PHP programming?
ABecause it always causes syntax errors
BBecause it can create tight coupling and reduce flexibility
CBecause PHP does not support inheritance
DBecause it makes code run slower
Step-by-Step Solution
Solution:
  1. Step 1: Understand drawbacks of inheritance

    Inheritance can tightly link classes, making changes harder and reducing flexibility.
  2. Step 2: Identify why it might be avoided

    To keep code modular and easier to maintain, developers sometimes avoid deep inheritance.
  3. Final Answer:

    Because it can create tight coupling and reduce flexibility -> Option B
  4. Quick Check:

    Inheritance drawback = Tight coupling [OK]
Quick Trick: Avoid inheritance if it causes tight coupling [OK]
Common Mistakes:
  • Thinking inheritance causes syntax errors
  • Believing PHP does not support inheritance
  • Assuming inheritance always slows code

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes