Bird
0
0

Which statement correctly describes the use of parent::methodName() in PHP?

easy📝 Conceptual Q2 of 15
PHP - Inheritance and Polymorphism
Which statement correctly describes the use of parent::methodName() in PHP?
AIt calls the method <code>methodName</code> from the child class itself.
BIt calls the method <code>methodName</code> from the parent class, even if overridden in the child.
CIt calls a static method only if <code>methodName</code> is declared static.
DIt can only be used outside class methods.
Step-by-Step Solution
Solution:
  1. Step 1: Understand method overriding

    When a child class overrides a method, parent::methodName() allows calling the original method from the parent.
  2. Step 2: Confirm usage

    This call works inside child class methods to access parent implementations.
  3. Final Answer:

    It calls the method methodName from the parent class, even if overridden in the child. -> Option B
  4. Quick Check:

    parent:: calls overridden parent method [OK]
Quick Trick: parent:: calls overridden parent method [OK]
Common Mistakes:
  • Thinking parent:: calls child class methods
  • Assuming parent:: only works with static methods
  • Using parent:: outside class context

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes