Bird
0
0

Which statement about traits in PHP is TRUE?

easy📝 Conceptual Q2 of 15
PHP - Interfaces and Traits
Which statement about traits in PHP is TRUE?
ATraits replace abstract classes
BTraits can contain properties and methods
CTraits cannot be used inside classes
DTraits can be instantiated directly
Step-by-Step Solution
Solution:
  1. Step 1: Review trait capabilities

    Traits can include both properties and methods to share code.
  2. Step 2: Evaluate other options

    Traits cannot be instantiated directly, must be used inside classes, and do not replace abstract classes.
  3. Final Answer:

    Traits can contain properties and methods -> Option B
  4. Quick Check:

    Trait features = Properties and methods [OK]
Quick Trick: Traits hold reusable code blocks including properties [OK]
Common Mistakes:
  • Trying to create objects from traits
  • Believing traits are standalone classes
  • Confusing traits with abstract classes

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes