Bird
0
0

Which of the following is the correct syntax to call a static method show() of class Test?

easy📝 Syntax Q12 of 15
PHP - Classes and Objects
Which of the following is the correct syntax to call a static method show() of class Test?
A<code>$obj->show();</code>
B<code>$obj::show();</code>
C<code>Test->show();</code>
D<code>Test::show();</code>
Step-by-Step Solution
Solution:
  1. Step 1: Recall static method call syntax

    Static methods are called using the class name and double colon (::).
  2. Step 2: Check each option

    Test::show(); uses Test::show(); which is correct syntax.
  3. Final Answer:

    Test::show(); -> Option D
  4. Quick Check:

    Static method call = ClassName::method() [OK]
Quick Trick: Use ClassName::method() to call static methods [OK]
Common Mistakes:
  • Using object arrow (->) to call static methods
  • Using object variable with :: operator incorrectly
  • Using class arrow (->) which is invalid

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes